Escolar Documentos
Profissional Documentos
Cultura Documentos
MATLAB has four control flow structures: the if statement, the for loop, the while loop, and the
switch statement.
1.1 ifend structure
MATLAB supports variants of if
(a) If end
(b) if else end
The simplest form of if is
(c) if elseifelseend
If expression
Statement
end
See some Examples -----if1.m---------ifelse2.m--------ifelseif3.m
1.2 Relational and logical operators
These operators compare two numbers by determining whether the comparison is true or
false.
Operator
Description
>
Greater than
<
Less than
>=
Greater than or equal to
<=
Less than or equal to
==
Equal to
~=
Not equal to
&
AND
|
OR
~
NOT
1.3 forend loop
The execution of a command is repeated at a fixed and predetermined number of times. Syntax
for variable=expression
Statements
End
for-nested.m]
5
6
7
8
9
Operator
Parantheses ()
Transpose (.), power (.^), matrix power(^)
Unary plus (+), unary minus (-), logical negation (~)
Multiplication (.*), right division (./), left division (.\),
matrix multiplication (*), matrix right division (/),
matrix left division (\)
Addition (+), Subtraction (-)
Colon operator (:)
Less than (<), less than or equal to (<=), greater (>),
greater than or equal to (>=), equal to (==), not equal to (~=)
Element-wise AND, (&)
Element-wise OR, (|)
If your examples are same in a group, it will deduct your marks. Make sure your examples are
different.