2. Mathematics and computation.
Analyze data.
Develop algorithms
Do simulation and modeling
Produce graphical displays and graphical user interfaces.
MATLAB is an interactive system whose basic data element is an array
that does not require dimensioning..
MATLAB is a software package that lets
you do:
3. MATLAB is an interactive system for doing numerical computations.
Powerful operations can be performed using just one or two
commands.
Powerful operations can be performed using just one or two
commands.
Easily ……………..
7. Notes
MATLAB is case sensitive.
MATLAB can handle integer, real, and complex variables.
Format: How MATLAB prints numbers
controlled by the "format" command
Try it!
Phi=(1+sqrt(6))/2
9. Command Window Management
One often does not want to see the result of intermediate calculations.
terminate the assignment statement or expression with semi–colon
>>x=3; y=6;
>>
Note also we can place several statements on one line, separated by
commas or semi-colon.
Clc command :Clear command window
Up and down recall previous command.
13. Vectors
MATLAB has two forms of vectors:
Row vectors
Column vector
Row vectors: they are lists of numbers separated by either commas or
spaces.
The number of entries is known as the"length" of the vector The
entries must be enclosed in square brackets.
v=[1 3,sqrt(25)];
14. Vectors
Examples:
v = [ 1 3, sqrt(5)]
v2 = [3+ 4 5]
v3 = [3 +4 5] � is v2=v3 ?!!!!!
We can do certain arithmetic operations with vectors of the same length
(v , v3)
Try adding v and v2.
15. Vectors
Suppose we want a vector starting from 1 up to 100 with increments of
one (i.e. 1 2…100).
Write 100 elements � time consuming process.
An easy way: v=[1:100].
Generally a : b : c produces a vector of entries
Starting with the value a,
Incrementing by the value b
Until it gets to c.
Example: 0.32:0.1:0.6
16. Vectors
So far, we have two methods for declaration:
X=[element1 element2 element3 ……. ]
(start : step : end)
Another declaration of the vector is:
Z=linspace(O,1O,11) � (start, end, no. of points)
Linear space
Increment = (end - start)/(N-1)
If X is a vector, then Y=sin(X), is also a vector with the same dimensions.
this direct relation between x,y
17. Extracting of bits vectors
Assume r = [1:2:6, -1:-2:-7];
To get the 3rd to 6th entries:
r(3:6)
What does r (6:-2:1) give?