MATLAB: Disp

display

if b>a & b>c
disp(b)
elseif c>a & c>b
disp(c)
else disp(a)
disp(a)
end
I have defined:
>> a
a =
24
>> b
b =
42
>> c
c =
64
when I run this the if/else works and i get 64
but it does not disp a afterwards. Why not?

Best Answer

The final disp(a) is within the scope of the last else. "else" does not terminate until an "end" -- you are not limited to providing only a single statement in an if or elseif or else clause.