vector.
A vector of length n can be visualized as matrix of size 1xn or nx1.
Matrix Calculations
Addition
Multiplication
Inverse
In matrix form the above system and its solution can be written
as
Loops
Two different types of loops exist in
MATLAB.
for and
while
for loop
A simple for loop to calculate and
display squares of numbers from 1 to 5.
while loop
While loop continue to execute if the given
condition is true.
A condition is true if it is not equal to 0.
A simple while loop to display numbers from
1 to 10 is shown here.
Logical Operators
AND, OR, and INVERT logical operations
can be performed in MATLAB.
The symbols used for these operators
are && , ||, and ~ respectively for
AND, OR, and INVERT.
A logical operation always results in a
1 or 0.
Less than
>
Greater than
==
Equal to
<=
>=
~=
Not equal to
if statement
if statement checks whether the condition
given to it is TRUE or FALSE.
if-else statement
If-else is used if we want to perform
two different tasks depending upon the
condition is TRUE or FALSE.
Functions in Matlab
Functions are actually computer
routines(programs) to perform specific
task.
Matlab is rich in built-in function
A function is called, user gives specific
input(s) to the function, which
generates the required output(s).
Plotting in Matlab
Matlab uses plot command to plot the
curves with different line style and
colors
Example follows:
Thank You