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
----
반응형
'유용한 지식 > Matlab' 카테고리의 다른 글
Get Matlab Excel Data | xlsread function (0) | 2020.09.24 |
---|---|
Using the Matlab 'for Statement' | Loop Statement (0) | 2020.09.24 |
Matlab Graph Axis Tick | Plot Advanced Edit1 (0) | 2020.09.24 |
Matlab subplot function (0) | 2020.09.24 |
Matlab Plot Function, Basic and Useful Tips (0) | 2020.09.24 |
댓글