Q:

In chemistry, the pH of an aqueous solution is a measure of its acidity. A solution with a pH of 7 is said to be neutral, a solution with a pH greater than 7 is basic, and a solution with a pH less than 7 is acidic

0

 In chemistry, the pH of an aqueous solution is a measure of its acidity. A solution with a pH of 7 is said to be neutral, a solution with a pH greater than 7 is basic, and a solution with a pH less than 7 is acidic. Create a vector of structures with various solutions and their pH values. Write a function that will determine acidity. Add another field to every structure for this. 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Ch8Ex19.m

% Create a vector of structures to store solution

% names and their pH values

phvals(2) = struct('solname', 'water', 'ph', 7);

phvals(1) = struct('solname', 'coffee', 'ph', 5);

new = addAcidity(phvals)

addAcidity.m

function outph = addAcidity(phvals)

% Determines acidity for solutions and adds

% a field to the phvals structures

% Format of call: addAcidity(vec of solutions structs)

% Returns new vector of structs with acidity field

outph = phvals;

for i = 1:length(phvals)

 if phvals(i).ph == 7

 outph(i).acidity = 'neutral';

 elseif phvals(i).ph < 7

 outph(i).acidity = 'acidic';

 else

 outph(i).acidity = 'basic';

 end

end

end

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now