ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf ·...
Transcript of ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf ·...
![Page 1: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/1.jpg)
uOttawa.cauOttawa.ca
ELG3125 Signal and System Analysis
Signal Manipulation and Graphics (Fall, 2016)
Presented by: Mohammad Khaki
School of Information Technology and Engineering
![Page 2: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/2.jpg)
uOttawa.ca
Outline
• Periodic Signals
• Signal Combination
• MATLab Graphing
• More examples
http://www.site.uottawa.ca/~mkhak052/TA-SignalSystemLab/
![Page 3: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/3.jpg)
uOttawa.ca
Continuous-Time Sinusoidal Signals
3
Let’s plot Sin signal with period T:
T=6; %period
t=0:0.01:60;
y=sin(2*pi/T.*t);
plot(t,y);
grid;
*If you don’t see grid use
“grid on” command!
Do you see grid now?
![Page 4: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/4.jpg)
uOttawa.ca
Exponential Function Signal
Let’s plot Exponential Function:
t=0:0.01:20;
omega=1;
y=exp(omega.*t);
plot(t,y),grid;
![Page 5: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/5.jpg)
uOttawa.ca
Plot Two Continuous-time Signals in OneGraph (Method1)
%Use plot function
%Sinusoidal 1
T=6; t=0:0.01:20;
y1=sin(2*pi/T.*t);
%Sinusoidal 2
y2=sin(4*pi/T.*t);
plot(t,y1,'r',t,y2,'b'),
grid;
![Page 6: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/6.jpg)
uOttawa.ca
Plot Two Continuous-time Signals in OneGraph (Method2) – use “hold on”
% Sinusoidal 1
T=6; t=0:0.01:20;
y1=sin(2*pi/T.*t);
plot(t,y1,'r');
hold on
%Sinusoidal 2
y2=sin(4*pi/T.*t);
plot(t,y2,'b');
grid on;
![Page 7: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/7.jpg)
uOttawa.ca
Square Wave(with period T)
t=0:0.01:20;
T=5; %period
y=sign(sin(2*pi/T.*t));
%or
%y=mod(t.*1/T,1)>1/2;
plot(t,y),grid;
axis([0 20 -1.5 1.5]);
grid on;
![Page 8: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/8.jpg)
uOttawa.ca
Discrete-Time Sinusoidal Signals
Let’s plot Sin signal with period N:
n=0:20;
m=1;
N=7; %period
y=sin(2*pi*m/N.*n);
stem(n,y),grid;
%plot() is for continuous signals and stem() is for discrete signals
![Page 9: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/9.jpg)
uOttawa.ca
Discrete-Time Sinusoidal Signals(Homework 1-26 b)
Let’s plot Cosine signal: 𝑥[𝑛] = cos(𝑛
8− 𝜋)
(Result in the next slide)
n=0:200;
x=cos(n./8-pi);
stem(n,x);
grid on;
![Page 10: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/10.jpg)
uOttawa.ca
X[n]=cos(n/8-pi) Result: NOT periodic: 𝑥 𝑛 ≠ 𝑥 𝑛 + 𝑁
![Page 11: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/11.jpg)
uOttawa.ca
Discrete-Time Sinusoidal SignalsHomework 1-26 c)
𝑥[𝑛] = cos(𝜋
8× 𝑛2)
𝑥[𝑛] = 𝑥 𝑛 + 𝑁Periodic and N=8
n=0:33;
x=cos(power(n,2)*pi/8);
stem(n,x,'b'),grid;
![Page 12: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/12.jpg)
uOttawa.ca
Discrete-Time Exponential Signals
Exponential signal:
n=0:10;
y=exp(0.5*n);
stem(n,y);
grid;
![Page 13: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/13.jpg)
uOttawa.ca
Addition of Two Continuous-Time Signals
t=0:0.01:20;
T1=2;
T2=4;
y1=cos(2*pi/T1*t);
y2=sin(2*pi/T2*t);
y3=y1+y2;
plot(t,y3),grid;
![Page 14: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/14.jpg)
uOttawa.ca
Addition of Two Discrete-Time Signals
n=0:60;
N1=2;
m1=3;
N2=4;
m2=2;
y1=cos(m1/N1*2*pi.*n);
y2=sin(m2/N2*2*pi.*n);
y3=y1+y2;
stem(n,y3),grid;
![Page 15: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/15.jpg)
uOttawa.ca
Multiplication of Two Discrete-Time Signalsn=-15:15;
x=cos(pi.*n/2).*cos(pi.*(n/4));
stem(n,x);
grid;
∗ 𝑥[𝑛] = 𝑥 𝑛 + 𝑁Periodic and N=8
![Page 16: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/16.jpg)
uOttawa.ca
3-D Plotting
• 3-D analog of plotting function.
• Function: plot3(x,y,z)
• When x, y and z are three vectors of the same length, it
plots a line in 3-D through the points whose coordinates are
the elements of x, y and z.
![Page 17: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/17.jpg)
uOttawa.ca
View
• 3-D graph viewpoint specification.
• Used together with plot3.
• Function: view(AZ,EL)
• AZ: Azimuth rotation in degree, which revolves z-axis,
with positive values indicating counter-clockwise rotation of
the viewpoint.
• EL: Elevation in degree, with positive values
corresponding to moving above the object.
![Page 18: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/18.jpg)
uOttawa.ca
Axis
• By default, Matlab finds the maximum and minimum of
data to choose the axis limits.
• Axis is used to control axis scaling and appearance.
• Function: axis([xmin xmax ymin ymax]) for 2-D plot.
axis([xmin xmax ymin ymax zmin zmax]) for 3-D plot.
• axis auto: returns the axis scaling to its default.
![Page 19: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/19.jpg)
uOttawa.ca
3D Plotting Example
T=6;
t=0:0.01:20;
y=exp(j*2*pi/T*t);
figure(1);
plot3(t,real(y),imag(y));
grid on;
axis square;
![Page 20: ELG3125 Signal and System Analysis - site.uottawa.camkhak052/TA-SignalSystemLab/LAB 2.pdf · ELG3125 Signal and System Analysis Signal Manipulation and Graphics (Fall, 2016) Presented](https://reader030.fdocuments.us/reader030/viewer/2022020717/5ad8e5627f8b9a3e578df1fb/html5/thumbnails/20.jpg)
uOttawa.ca
Thank you!