Matlab Exercise 3
Matlab Exercise 3
OBJECTIVE:
PROGRAM:
Basic Signals
The following exercises will introduce you to basic signal plotting.
Write a short description on the blank lines regarding its respective Matlab code.
fs = 8000; ___________________________________________
t = 0:1/fs:3;
z1 = sawtooth(2*pi*t); ___________________________________________
figure(1) ___________________________________________
subplot(211) ___________________________________________
plot(t,z1)
axis([0 3 -1 1]) ___________________________________________
z2 = square(2*pi*t); ___________________________________________
subplot(212) ___________________________________________
plot(t,z2)
axis([0 3 -1 1]) ` ___________________________________________
t = linspace(0,3,200); ___________________________________________
z3 = t.^2; ___________________________________________
z4 = sin(10*t); ___________________________________________
z = z3.*z4; ___________________________________________
figure(2) ___________________________________________
subplot(211) ___________________________________________
stem(t,z)
xlabel(‘Time’)
title(‘Discrete Product of Functions’)
subplot(212) ___________________________________________
plot(t,z)
xlabel(‘Time’)
title(‘Continuous Product of Functions’) ________________________________
1
Signals, Spectra, & Signal Processing Laboratory | eʃernαn dz
n = -10:10; ___________________________________________
x = exp((-.1+j*.3)*n); ___________________________________________
r = real(x); ___________________________________________
i = imag(x); ___________________________________________
m = abs(x); ___________________________________________
p = angle(x); ___________________________________________
figure(3) ___________________________________________
subplot(221) ___________________________________________
stem(n,r) ___________________________________________
title('real part')
xlabel('n')
subplot(222) ___________________________________________
stem(n,i)
title('imaginary part')
xlabel('n')
subplot(223) ___________________________________________
stem(n,m)
title('magnitude part')
xlabel('n')
subplot(224) ___________________________________________
stem(n,p)
title('phase part')
xlabel('n')
Now plot the following signals. Use a two-paneled window for each figure. Use
subplot(2,1,?) to display both plots in the same window. For items 1 to 3, plot
each part of the two signals on the first panel, then plot the product (difference in
item 3) on the second panel. For number 4, plot the real and imaginary part on
the first panel, then plot the magnitude and phase part on the second. Use
legend to identify signals plotted on a single panel. Use grid for all plots that
starts t = 0.