Professional Documents
Culture Documents
Familiarization With Matlab: Kandarpa Kumar Sarma
Familiarization With Matlab: Kandarpa Kumar Sarma
zA Picture Speaks a
Thousand Words
z Desktop Logo
z Command
Prompt
z Variable-
z integer,
z floating point,
z character,
z strings.
z Let X=1:5;
z To square all the
elements in the
vector simply type
Y=X.^2
z To change a row
vector to a column
vector, just type X'
z Let X=1:5;
z Let Y=2*X;
z Z=X.*Y; It assigns
the value of the
product between the
vectors X and Y.
z It can be started
by simply clicking
the new graphic
in the menu bar.
It starts a new/
blank editor
window.
Entering Matrices:
z Enter an explicit list of elements.
z Load matrices from external data files.
z Generate matrices using built-in functions.
z Create matrices with your functions (m-
files).
Clc;
Clear all;
Close all;
t =
0:pi/100:2*pi;
y1=sin(t);
y2=sin(t+pi/2);
plot(t,y1,t,y2)
grid on
RC in Electronics and Instumentation,
2010 39
Matrices…..
A = [ 1 6 3 2 1 3;
5 1 0 1 1 8;
9 6 7 1 0 2;
4 1 5 1 4 1]
z Separate the elements of a row with blanks or
commas.
z Use a semicolon, ; , to indicate the end of each row.
z Surround the entire list of elements with square
z brackets, [ ].
z Clc;
z Clear all; B=inv(A)
Warning: Matrix is close to singular or
z Close all; badly scaled. Results may be
inaccurate. RCOND = 1.306145e-017.
z A=magic(4);
B=
z B=inv(A) % to
calculate the 1.0e+014 *
inverse of matrix A. 0.9382 2.8147 -2.8147 -0.9382
2.8147 8.4442 -8.4442 -2.8147
-2.8147 -8.4442 8.4442 2.8147
-0.9382 -2.8147 2.8147 0.9382
z To find an
approximation to the
eigen values of a
matrix eig(A); C=eig(A)
z C=eig(A) is a vector C=
containing the eigen
34.0000
values of a square 8.9443
matrix A. -8.9443
0.0000
zh = .001;
z x = 0:h:pi;
z diff(sin(x.^2))/h
z It means differentiation of sin x2 w.r.t h
for given values of h and x.
π 2π
f ( x, y ) = ∫ π∫ ( x cos
0
y + y sin x )dydx
z Simulink facility
can be invoked
by typing
simulink in
the command
window
z Continuous
time domain
operations
z Dead zones
z Quantizer
z Rate Limiter
z Resources for
signals and
processes in
discrete domain