LAB MANUAL SUBJECT: SIGNALS AND SYSTEMS LABORATORY PAPER CODE: EC-209 DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING DELHI TECHNOLOGICAL UNIVERSITY, DELHI-110042
Jan 12, 2016
LAB MANUAL
SUBJECT: SIGNALS AND SYSTEMSLABORATORY
PAPER CODE: EC-209
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
DELHI TECHNOLOGICAL UNIVERSITY, DELHI-110042
SIGNALS AND SYSTEMS LABORATORY EC-209
LIST OF EXPERIMENTS
1. Write a MATLAB code to generate different types of Signals.2. Write a MATLAB code to perform an Arithmetic operation on signal’s
Addition, Subtraction, Multiplication and Division.3. Write a MATLAB code to perform signal processing operations: Time
shifting, Time scaling, and Time inversion.4. Write a MATLAB code to perform Convolution of two signals.5. Write a MATLAB code to determine response of LTI system for a given
input signal.6. Write a MATLAB code to determine Fourier transform of a given input
signal and plot its Magnitude and Phase spectra.
7. Write a MATLAB code to generate Frequency Spectrum of a Periodicsignal.
8.Write a MATLAB code to generate Inverse Fourier transform of a signal.
9. Write a MATLAB code to determine Frequency response of FIR system.
10. Write a MATLAB code to determine Frequency response of Infinite ImpulseResponse system.
11. Write a MATLAB code to determine Z-transform and plot its poles andzeros location in z-plane.
SIGNALS AND SYSTEMS LABORATORY EC-209
EXPERIMENT NO.:-1
OBJECTIVE: - Write a Matlab code to generate different types of basic Signals.
HARDWARE /SOFTWARE REQUIRED:-
1) MATLAB 7.6 Version2) Computer3) PrinterTheory:-Basic idea of different types of basic signals i.e.
i. Unit impulse function
0 ; t ≠ 0
ii. Unit step function
0; t<0
SIGNALS AND SYSTEMS LABORATORY EC-209
III Ramp function
IV exponential function0 ; t<0
There can be different cases in which ‘a’ value differences.
• ‘a’ can be real (i) real (ii) negative• ‘a’ can be a purely imaginary• ‘a’ can be complex with both real and imaginary part.
Program Code:
t = -20:20;t1 = -5:0.01:5;t2 = -5:5;unit_imp = [zeros(1,20),1,zeros(1,20)];unit_step = [zeros(1,20),ones(1,21)];i=1;for k=-20:20
if k>0ramp(i) = k;
elseramp(i) = 0;
endi = i+1;
endexpo = exp(-t2);sinu = sin(t1);subplot(3,2,1);stem(t,unit_imp);
SIGNALS AND SYSTEMS LABORATORY EC-209
xlabel('Time');ylabel('Unit Impulse signal');grid on;
subplot(3,2,2);stem(t,unit_step);xlabel('Time');ylabel('Unit Step signal');grid on;
subplot(3,2,3);stem(t,ramp);xlabel('Time');ylabel('Ramp signal');grid on;
subplot(3,2,4);stem(t2,expo);xlabel('Time');ylabel('Exponential signal')grid on;Observation/Plot
Result:-Practical result is closely matched with experimental result.
SIGNALS AND SYSTEMS LABORATORY EC-209
EXPERIMENT NO.:-2
OBJECTIVE:-Write a Matlab code to perform arithmetic operations for a signal such asaddition, subtraction, multiplication and division.HARDWARE/SOFTWARE REQUIRED:-1) MATLAB version7.62) Computer3) PrinterTheory:- The theoretical results of various arithmetic operations such as addition,multiplications, subtraction of two signals (say sine wave and ramp signal).Let us consider two signalsx(t)=sin(wt)y(t)-cos(wt)
Signal processing operation on dependent variable is of the following types:-1) Addition
z(t)=x(t)+y(t)=sin(wt)+cos(wt)
2)Subtractionz(t) =x(t)-y(t)
=sin(wt)-cos(wt)3) Multiplication
z(t)=x(t)*y(t)=sin(wt)*cos(wt)
4) Divisionz(t)=x(t)/y(t);y(t)≠0
=sin(wt)/cos(wt)Program Code:t = -5:0.1:5;x = sin(t);y= cos(t);x_addition = x+y;x_division = x./y;x_multiplication = x.*y;x_subtraction = x-y;grid on;
subplot(2,3,1);plot(t,x);grid on;xlabel('Time');ylabel('Original Signal');subplot(2,3,2);plot(t,x_addition);
SIGNALS AND SYSTEMS LABORATORY EC-209
grid on;xlabel('Time');ylabel('Added Signal');
subplot(2,3,3);plot(t,x_division);grid on;xlabel('Time');ylabel('Divided Signal');
subplot(2,3,4);plot(t,x_multiplication);grid on;xlabel('Time');ylabel('Multiplied Signal');subplot(2,3,5);plot(t,x_subtraction);grid on;xlabel('Time');ylabel('subtracted Signal');
Observation/Plot
Result:-Practical result is closely matched with experimental result.
SIGNALS AND SYSTEMS LABORATORY EC-209
EXPERIMENT NO.:-3
OBJECTIVE: -Write a MATLAB code to perform signal processing operations time scalingtime shifting time inversion.Hardware/Software required:-1) MATLAB version7.62) Computer3) PrinterTheory:-Various signal processing operation that can be performed on a signal are:-
x(t)=
0 3
• Time inversion: -if x (t) is the original signal then x (-t) is the time inverted signal.
-3 0• Time scaling: - if x (t) is a given signal then x(t) is time scaled by ‘a’ is given below;
0 1• Time shifting:- if x(t) is a given signal then x(t) is time shifted by t0 can be obtained
• Delayed x(t-t0 )
0 t0 3-to
SIGNALS AND SYSTEMS LABORATORY EC-209
• Advanced x(t+t0)
t0+2 0 1
Program Code: (Example)f = input('Enter frequency of the signal -> ');w = 2*pi*f;t = 0:1/(1000*f):1/f;X = sin(w*t);
%Time Scalingk = input('Enter the value by which you want to scale the signal (compress or elongate) -> ');Xsc = sin(k*w*t);%Time Shiftingt1 = input('Enter the value of time by which you want to advance (enter positive value) OR delay(enter negative value) the signal ->');Xsh = sin(w*(t-t1));%Time InversionXin = sin(-w*t);
%Plotting the transformed and original signalshold on;plot(t,X,'-k','Linewidth',2); grid on;plot(t,Xsc,':r','Linewidth',2); grid on;plot(t,Xsh,'-g','Linewidth',2); grid on;plot(t,Xin,'-.b','Linewidth',2); grid on;xlabel('Time');ylabel('Amplitude of the signal');
SIGNALS AND SYSTEMS LABORATORY EC-209
Observation/Plot
Result:-Practical result is closely matched with experimental result.
SIGNALS AND SYSTEMS LABORATORY EC-209
Experiment NO.:-4
OBJECTIVE:- Write a program to find the Convolution of two signals.Hardware/Software required:-1) MATLAB version 7.62) Computer3) PrinterTheory:-The below equation defines the integral convolution of 2 time signals x (t) and h (t) denoted by
Or
Program Code:
a=[1 2 3];b=[4 5 6];i=length(a);j=length(b);A=[a,zeros(1,i)];B=[b,zeros(1,j)];for k=1:i+j-1y(k)=0;for l=1:i
if (k-l+1>0)y(k)=y(k)+A(l)*B(k-l+1);
elseend
endend;stem (y);
ylabel('Y[k]');xlabel('----->n');title('convolution of two signals');
SIGNALS AND SYSTEMS LABORATORY EC-209
Observation/Plot
Result:-Practical result is closely matched with experimental result.
SIGNALS AND SYSTEMS LABORATORY EC-209
Experiment NO.:-5
OBJECTIVE:-Write a matlab code to determine the LTI response of a given Input signal.
Hardware/Software required:-
1) Matlab version 7.6
2) Computer
3) Printer
Theory: - LTI system or linear time invariant system
LTI response of the signal y(t)
i.e convolution of two signal x(t) and h(t) is given as
m=length (x); n=length (h) the vector y is of length m+n-1, where kth element is
Program Code: (Example)
t = 0:0.01:10;x = exp(-t);h = [ones(1,1001)];Lx = length(x);Lh = length(h);Ly = Lx + Lh -1;for p=1:Ly
sum=0;for k=1:p
if(k<=Lx && k>=(p+1-Lh))sum = sum + x(k).*h(p+1-k);
SIGNALS AND SYSTEMS LABORATORY EC-209
endendy(p) = sum;
endt1 = 0:0.01:(Ly-1)*0.01;
%Input Signalsubplot(2,2,1);plot(t,x);title('Input Signal');xlabel('Time'); ylabel('Amplitude of the signal');
%Impulse Responsesubplot(2,2,2);plot(t,h);title('Impulse Response');xlabel('Time'); ylabel('Amplitude of the signal');
%Output of the LTI Systemsubplot(2,2,[3:4]);plot(t1,y);title('Output of the LTI System');xlabel('Time'); ylabel('Amplitude of the signal');
Observation/Plot
Result:-Practical result is closely matched with experimental result.
SIGNALS AND SYSTEMS LABORATORY EC-209
Experiment No:-6
OBJECTIVE:- Write a matlab code to generate Fourier transform of a given Input signal andplot its Magnitude and Phase spectra.Hardware required/software required:-1) MATLAB version 7.62) Computer3) PrinterTheory:-Fourier transform is divided into 2 parts
• Continuous time Fourier transformThis is applicable for aperiodic function and periodic functions
And the corresponding function isX(t)= Fourier transform of a signal can be obtained by using FFT function in matlab.The plot of X(W) vs w is called as magnitude spectraAnd angle of X(W) vs w is known as phase spectra.• Discrete time Fourier transform
It is divided for periodic function.
Program Code: (Example)
x =[1,1,1,1,zeros(1,4)];n=8;X= fft(x,n);magx= abs(X);phase=angle(X)*180/pi;subplot(2,2,1);plot(x,'k');xlabel('n');ylabel('Signal');title('Input signal');
SIGNALS AND SYSTEMS LABORATORY EC-209
subplot(2,2,2);plot(magx);grid;xlabel('n');ylabel('Magnitude');title('Magnitude plot');subplot(2,2,3);plot(phase);grid;xlabel('n');ylabel('degrees');title('Phase plot')
Observation/Plot
Result:-Practical result is closely matched with experimental result.
SIGNALS AND SYSTEMS LABORATORY EC-209
Experiment No:-7
OBJECTIVE: - Write a matlab code to generate frequency spectrum of a periodic signal.Hardware/Software required:-1) MATLAB version 7.62) Computer3) PrinterTheory:-A continuous time signal x(t) to be periodic if there is a positive non zero value of t forwhich
All t ----- (1)
The fundamental period T0 of x (t) is the smallest positive value of T for which equation (1) isnot satisfied and 1/t0=f0 is referred as fundamental frequency.Two basic example of periodic signal are the real sinusoidal signal
The complex exponential Fourier series representation of a periodic signal x(t) with To asfundamental period
wo=2π/To
Where are the complex Fourier Coefficients
Program Code: (Example)
t = 0:0.01:10;%Train of Pulsesx = [ones(1,201),zeros(1,99),ones(1,201),zeros(1,99),ones(1,201),zeros(1,99),ones(1,101)];T = 3;w = 2*pi/T;
SIGNALS AND SYSTEMS LABORATORY EC-209
dtau = 0.01; %Difference between two time intervals as taken in matlab;for k=-10:10
sum = 0;i=1;for tau=0:dtau:T
exp_part = exp(-j*w*k*tau)*dtau;sum = sum + exp_part.*x(i);i=i+1;
enda(k+11) = sum;
end
for i=1:21mag(i) = abs(a(i));phase(i) = angle(a(i));
endk=-10:10;
%Original Signalsubplot(2,2,[1:2]);plot(t,x);title('Input Signal (A Pulse Train)');xlabel('Time');ylabel('Amplitude of the signal');%Magnitude Spectrasubplot(2,2,3);stem(k,mag);title('Magnitude Spectra');xlabel('k \rightarrow');ylabel('Magnitude');%Phase Spectrasubplot(2,2,4);stem(k,phase,'Linewidth',1.2)title('Phase spectra');xlabel('k \rightarrow');ylabel('Phase');
SIGNALS AND SYSTEMS LABORATORY EC-209
Observation/Plot
Result:-Practical result is closely matched with experimental result.
SIGNALS AND SYSTEMS LABORATORY EC-209
Experiment No.:– 8
OBJECTIVE:-Write a matlab code to generate inverse Fourier transform of a signal.
Hardware/Software Requirements:1) MATLAB version 7.62) Computer/Laptop2) PrinterTheory:- Inverse Fourier transform is used to convert a signal in frequency domain to a signal intime domain.If X(w) is the Fourier transform of a signal then, the original signal x(t) or inverse Fouriertransform of X(w) is given by:-
In MATLAB, we can use a direct command to evaluate the inverse Fourier transform i.e.d=ifft(x);Program Code: (Example)w=-100:.1:100;X = 1./(1+w.^2)dw = 0.1;m=1;for t=0:0.01:10
i=1;sum=0;for w=-100:dw:100
sum = sum + X(i)*exp(j*w*t)*dw;i=i+1;
endx(m) = sum;m=m+1;
endw=-100:.1:100;t=0:.01:10;
%given signalsubplot(2,1,1);plot(w,X);title('Given signal in Frequency domain');xlabel('Frequency \rightarrow');ylabel('X(w)');grid on;
%signal in time domainsubplot(2,1,2);
SIGNALS AND SYSTEMS LABORATORY EC-209
plot(t,x);title('Signal obtained via Inverse FT');xlabel('Time \rightarrow');ylabel('x(t)');grid on;
Observation/Plot
Result:-Practical result is closely matched with experimental result.
SIGNALS AND SYSTEMS LABORATORY EC-209
Experiment No.:-9
OBJECTIVE:-Write a Matlab code to perform and plot the Frequency response and Phaseresponse of FIR system.Hardware/Software Required:-1) MATLAB version 7.62) Computer3) PrinterTheory:- [h,p]=-freqz(ba,a,w) returns the frequency response vector h and the correspondingangular frequency vector for the digital filter whose transfer function is determined by the (realor complex) numerator and denominator polynomial represented by the vector b and arespectively. The vector h and p are both of length w has values ranging from 0 to pi per sample.
Freqz generally uses an fft algorithm to compute the frequency response.Program Code: (Example)h=[1,2,3,4];a=[1 2 3 4];b=[1];w=-pi:.01:pi;H=freqz(b,a,h);% plot of the impulse response of the systemsubplot(3,1,1);plot(h);grid on;xlabel('time');ylabel('h[n]');title('Impulse Response');% plot of the magnitude of frequency response of the systemsubplot(3,1,2)plot(w,abs(H));grid on;title('plot of the magnitude response ');xlabel('w');ylabel('|H[w]|');
% plot of the phase of frequency response of the systemsubplot(3,1,3)plot(w,angle(H));grid on;title('plot of the magnitude response ');xlabel('w');
SIGNALS AND SYSTEMS LABORATORY EC-209
ylabel('<H[w]');
Observation/Plot
Result:-Practical result is closely matched with experimental result.
SIGNALS AND SYSTEMS LABORATORY EC-209
Experiment No.:-10
OBJECTIVE:-Write a Matlab code to perform and plot the frequency response and phaseresponse of IIR system.Hardware/Software Required:-1) MATLAB version 7.62) Computer3) PrinterTheory:- a system whose impulse response or no. of non zero values of the output is infinite iscalled infinite impulse response IIR system.Let x (t) be the input signal. Let h(t) be the impulse response &Let y(t) be the response of thesystem.Taking Fourier transform, of the three. We get X (w), Y(w) &h(w)Y (t)=x(t)*h(t)Taking Fourier transformY(w)=X(w)H(w)H (w)=Y(w)/X(w)H (w) is called frequency response of system.Program Code: (Example)h1=(0.5)^n;a=[1,-0.5];b=[1];w=-pi:.01:pi;[h,p]=freqz(b,a,h);
% plot of the magnitude of frequency response of the systemsubplot(2,1,1)plot(w,h);grid on;title('plot of the magnitude response ');xlabel('w');ylabel('|H[w]|');
% plot of the phase of frequency response of the systemsubplot(2,1,2)plot(p);grid on;title('Phase response ');xlabel('w');ylabel('<H[w]');
Observation/Plot
SIGNALS AND SYSTEMS LABORATORY EC-209
Result:-Practical result is closely matched with experimental result.
SIGNALS AND SYSTEMS LABORATORY EC-209
Experiment No.:-11
OBJECTIVE:-Write a Matlab code to plot poles &zeros of the given Z transform of signal.Hardware/Software Required:-1) MATLAB version 7.62) Computer3) Printer
THEORY:- A pole-zero plot shows the location in the complex plane of the poles and zeros ofthe transfer function of a dynamic system, such as a controller, compensator, sensor, equalizer,filter, or communications channel. By convention, the poles of the system are indicated in theplot by an X while the zeroes are indicated by a circle or O.A pole-zero plot can represent eithera continuous-time (CT) or a discrete-time (DT) system. For a CT system, the plane in which thepoles and zeros appear is the s plane of the Laplace transform. In this context, theparameter s represents the complex angular frequency, which is the domain of the CT transferfunction. For a DT system, the plane is the z plane, where z represents the domain of the Z-transform. This function displays the poles and zeros of discrete-time systems.zplane(b,a) where b and a are row vectors, first uses roots to find the zeros and poles of thetransfer function represented by numerator coefficients b and denominator coefficients a. Thetransfer function is defined in terms of z-1:
Zplane (b,a) plots the zeros specified in column vector b and the poles specified in column vectora in the current figure window. The symbol 'o' represents a zero and the symbol 'x' represents apole. The plot includes the unit circle for reference. If z and p are arrays, zplane plots the polesand zeros in the columns of z and p in different colors.Program Code: (Example)b= [1 0 0 -8];a= [1 0 -1];Zplane (b, a);Observation/Plot