If Else

If – else statements are a type of conditional statement which performs an action based on whether your expression is true or false.

The matlab command is :

if x == value1
  
elseif x == value2
  
else
  
end

For example

if x == 1
  disp(‘I am numero uno’);
elseif x==2
  disp(‘I am the first prime number’);
else
  disp(['I am the number : ',int2str(x)]);
end
Bookmark and Share