In chemistry, the pH of an aqueous solution is a measure of its acidity. A solut
ID: 3544437 • Letter: I
Question
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.
A structure is created to store the PH value of a solution. This structure has two fields: one is called 'SolutionName', and the other is 'PH'. An example of such a variable is created as:
sol1 = struct('SolutionName', 'water', 'PH', 7);
Write a function that will take in one such a structure variable as the input argument, determine its acidity, add another field 'acidity; with the determined value to this structure, and return this new structure as the output variable.
For example, if the above sol1 is the input variable, the output variable would be:
OutputVar =
SolutionName: 'water'
PH: 7
Acidity: 'neutral'
Explanation / Answer
function argnew = stracidity(arg)
if arg.PH < 7
argnew=arg;
argnew.acidity='Acidic';
else if arg.PH == 7
argnew=arg;
argnew.acidity='Neutral';
else
argnew=arg;
argnew.acidity='Basic';
end
end
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.