Introduction To Matlab& Signals: Defining A Scalar
Introduction To Matlab& Signals: Defining A Scalar
Introduction To Matlab& Signals: Defining A Scalar
Arithmetic operations
x=[ 1 2 3 4 5]
x=
12345
x= 2 * x
x=
2 4 6 8 10
x= x / 2
x=
12345
y=[12345]
y=
12345
z=x+y
z=
2 4 6 8 10
point by point mult/div use “.“
W = x.*y
W=
1 4 9 16 25
Matlab has a large number of built in functions, some operate on each point of a
vector/matrix:
log([1 2 3 4])
ans =
0 0.6931 1.0986 1.3863
round([1.5 2; 2.2 3.1])
ans =
22
23
a=[1 4 6 3]
a=
1463
sum(a)
ans =
14
mean(a)
ans =
3.5000
max(a)
ans =
6
a =[1 2 3; 4 5 6]
mean(a) %mean of each column
max(a) %max of each column
max( max([1 2 3; 4 5 6]) ) %to obtain max of matrix
Let
a = [1 1 3 4 1]
a=
11341
ind = (a == 1)
ind =
11001
ind = (a < 1)
ind =
00000
ind = (a > 1)
ind =
00110
ind = (a <= 1)
ind =
11001
ind = (a >= 1)
ind =
11111
ind = (a ~= 1)
ind =
00110
b) t = 0:0.2:2*pi;
plot(t,sin(t))
c) t= 0:0.02:2*pi;
plot(t,sin(t))
title('CT signal plot')
xlabel('t (Seconds)')
ylabel('y(t)')
a) n = -10: 10;
f = n >= 0;
stem(n,f)
ACTIVITY:
I. Provide the snapshot of all the codes mention in STEP 3.
II. Provide the snapshot of all the codes mention in STEP 4.
III. Provide the snapshot of all the codes mention in STEP 8.
IV. Provide the snapshot of all the codes mention in STEP 9.
V. Write a MATLAB program to plot 6 different continuous sin signals in one window.
Provide the snapshot of the code and the graph.
VI. Write a MATLAB program to plot 4 different continuous sin signals using subplot
command. Provide the snapshot of the code and the graph.
VII. Repeat above 2 steps for discrete signals.
Provide the snapshot of all the codes mention in STEP 3.
Write a MATLAB program to plot 4 different continuous sin signals using subplot
command. Provide the snapshot of the code and the graph.
Write a MATLAB program to plot 6 different continuous sin signals in one window.
Provide the snapshot of the code and the graph.
Provide the snapshot of all the codes mention in STEP 9.