Hi, my code is as shown below, i tried as switch function instead of else if statement. However, the code is taking only integer numbers, for decimal numbers showing 'out of range'.
function category = pH21Category(pH)
switch true
case any(pH == 0:2)
category = 'Strongly acidic';
case any(pH == 3:5)
category = 'Weakly acidic';
case ismember(pH,6:8)
category='Neutral';
case ismember(pH,9:11)
category='Weakly Basic';
case ismember(pH,12:14)
category=('Strongly basic');
otherwise
category=('out of range');
end
Best Answer