MATLAB: What is wrong with this if-elseif-else function

if/elseif/else

what is wrong with it

Best Answer

The main problem is this line
elseif( userWeight >= 50 )
should be this instead
elseif( userWeight <= 140 )
And then the remaining parts of the if-then-else aren't really needed. The way you have it coded now, if userWeight is 500 they will get a dosageAmount of 20 because they will match that second branch test.