examples of if else in matlab

0

execute statements if condition is true 

 

if expression

    statements

elseif expression

    statements

else

    statements

end

 

the elseif and else blocks are optional

All Contributions

let us consider an example to find a large or less than a specific number.

If a = 5 then we will find the number a is less than 10 or not.

a = 5
if ( a < 10 ) 
    disp ( ' number is less than 10 ' ) 
else
   disp ( ' number is large than 10 ' ) 
end

Output:

a = 5

number is less than 10

total contributions (1)

New to examplegeek.com?

Join us