Professional Documents
Culture Documents
Introduction Lab: Objectives
Introduction Lab: Objectives
COMMANDS:VECTOR ADDRESSING:
To define a vector in matlab first chose a variable and then give it a value.i.e (both
have same results.)
V=[1 2 3 4 5 6 7 8 9 10]
&
EXAMPLES:
To make a new vector from two vectors first define these two and then
A=[1 2 3]
&
Now
C=[A+B]
The result is
C=[1 2 3 4 5 6]
B=[4 5 6]
EXAMPLES:
1):
X=[1 2 3; 4 5 6; 7 8 9]
If X(1,:)
If X(|:,1)
2): To create a matrix such that its all entries should be zero or one then write
3): If we have a matrix A then to find the size of that matrix we use command
[
Size(A)
]
4): For transpose of a matrix A we use command
[ B=A ]
[eye(n,m)]
[diag(A)]
[triu(A)]
[tril(A)]
[inv (A)]
Examples:
1):
t=1:0.1:10
&
y=cos(t)
then
2): For plotting more than one graph on the same graph-window we use
[
plot(t1 y1 t2 y2)
3): For plotting more than one graph on the same graph we use
[
4): For changing the scale of axis we use command [ axis(xmini xmax , ymini ymax) ]
5): For labeling on a graph we use command
[xlabel(time) , ylable(amplitude)
&
title(vector)]
plot(t,y,r)
grid
[ imaginary (z)]
[ real(z)]
[ angel(z)]
[ conj(z)]
f=10Hz
First to plot this wave we have to find the time period from frequency of 10Hz.
So
T=1/f
T=1/10
T=0.1
T=1/20000
T=0.0002
t=[0:0.0002:0.2];
A=1;
f=10000;
y=A*sin(2*pi*f*t);
plot(t,y)
Conclusion:In this lab we learn about some basic commands of matlab.i.e. ploting
of vectors, sinosiod signals(continues time & discrete time signals), matrices and
complex numbers. We attempt their different methods of initiating and some
examples. At the end of this lab, two tasks were given which were performed
successfully.
Now after performing this lab I am able to use matlab with its basic commands.
Assignment
Title :