유용한 지식/Matlab
Using Matlab 'if Statement' | Assumption Statement
그래도_明
2020. 9. 24. 17:05
Using Matlab 'if Statement' | Assumption Statement
'If statement' is confusing each time it is written because the rules vary depending on all programming languages.
I'll leave you an example for the matlab, so if you don't remember, it'll be convenient to scratch it quickly and correct it.
%% if-Statement Example Code
if a == b
display('a and b are same')
elseif a > b
display('a is bigger than b')
else
display('b is bigger than a')
end
Simply put, it is a code that compares the size of a and b and displays the sentence.
After if starts, write down both elseif and esle and write end only once at the end. Let's be careful not to space out in elseif.
The result is as follows when a=1 b=2 is added.
----
%% if-Statement Example Code
if a == b
display('a and b are same')
elseif a > b
display('a is bigger than b')
else
display('b is bigger than a')
end
----
반응형