MATLAB: Using an ELSEIF statement under another IF

elseelseifif

Hi,
Is it possible to check for a condition, and if that condition is true, check for more? If so, can you please explain? Here's an example of what I mean
if input < 1
if input2 < 1
% then do this

if input2 < 2
% then do this
end

Best Answer

Here is an example:
input = input('Please insert an integer\n');
if input < 10
if input < 5
fprintf('Your input is less than 5\n');
end
if input > 5
fprintf('Your input is greater than 5\n');
end
if input == 5
fprintf('Your input is 5\n');
end
else
fprintf('Your input is greater than 10\n')
end
Make sure to end your if statements with an end.
Related Question