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
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:8| Question number:19.8
All Answers
total answers (1)
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