MATLAB: How to make an array and add netural, acid, or base depending on the ph level? Is it easier to use a .cvs file or make a string? Im not sure how to do this problem.

chemistrystring

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

Best Answer

pH = 1:14 ;
for i = 1:length(pH)
val = pH(i) ;
if val < 7
fprintf('pH = %f,solution is acidic\n',val) ;
elseif val ==7
fprintf('pH = %f,solution is neutral\n',val) ;
elseif val > 7
fprintf('pH = %f,solution is basic\n',val) ;
end
end
Related Question