LAB MANUAL
SUBJECT: SIGNALS AND SYSTEMS LABORATORY PAPER CODE: EC-209
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
DELHI TECHNOLOGICAL UNIVERSITY, DELHI-110042
LIST OF EXPERIMENTS
1. 2. 3. 4. 5. 6.
7.
Write rite a MAT MATL LAB code code to gener enerat atee dif diffferen erentt ty types pes of of Sig Signal nals. Writ Wr itee a MAT MATLA LAB B cod codee to perf perfor orm m an an Arit Arithm hmet etic ic oper operat atio ion n on on sign signal al’s ’s Addition, Subtraction, Multiplication and Division. Writ Wr itee a MATL MATLAB AB code code to perf perfor orm m sign signal al proc proces essi sing ng oper operat atio ions ns:: Tim Timee shifting, Time scaling, and Time inversion. Write rite a MAT MATL LAB code code to per perfor form Con Convo vollutio ution n of of two two sig signals nals.. Writ Wr itee a MAT MATLA LAB B cod codee to to dete determ rmin inee res respo pons nsee of of LTI LTI syst system em for for a giv given en input signal. Writ Wr itee a MAT MATLA LAB B cod codee to to dete determ rmin inee Fou Fouri rier er tran transf sfor orm m of of a give given n inp input ut signal signal and plot its Magnitude Magnitude and Phase spectra. spectra. Writee a MATL Writ MATLAB AB code code to gene genera rate te Freq Freque uenc ncy y Spe Spect ctru rum m of of a Perio Periodi dicc signal. Write a MATLAB code to generate Inverse Fourier transform of a signal.
8. 9. 10. 11.
Writ Wr itee a MAT MATLA LAB B cod codee to dete determ rmin inee Freq Freque uenc ncy y res respo pons nsee of of FIR FIR syst system em.. Writee a MATL Writ MATLAB AB code code to dete determ rmin inee Freq Freque uency ncy resp respon onse se of of Infi Infini nite te Impu Impulse lse Response system. Writ Wr itee a MAT MATLA LAB B code code to to dete determ rmin inee Z-tr Z-tran ansf sfor orm m and and plot plot its its pol poles es and and zeros 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 Version 2) Computer 3) Printer Theory: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 function
0 ; 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>0 ramp(i) = k; else ramp(i) = 0; end i = i+1; end expo = 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 as addition, subtraction, multiplication and division. HARDWARE/SOFTWARE REQUIRED:1) MATLAB version7.6 2) Computer 3) Printer Theory:- The theoretical results of various arithmetic operations such as addition, multiplications, subtraction of two signals (say sine wave and ramp si gnal). Let us consider two signals x(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)Subtraction z(t) =x(t)-y(t) =sin(wt)-cos(wt) 3) Multiplication z(t)=x(t)*y(t) =sin(wt)*cos(wt) 4) Division z(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 scaling time shifting time inversion. Hardware/Software required:1) MATLAB version7.6 2) Computer 3) Printer Theory: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 if x (t) is a given signal then x(t) is time scaled by ‘a’ is given below;
•
Time scaling: -
•
0 1 Time shifting:- if x(t) is a given signal then x(t) is time shifted by t 0 can be obtained • Delayed x(t- t0 )
0
t0
3-to
SIGNALS AND SYSTEMS LABORATORY EC-209
•
Advanced x (t+t 0)
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 Scaling k = input('Enter the value by which you want to scale the signal (compress or elongate) -> '); Xsc = sin(k*w*t); %Time Shifting t1 = 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 Inversion Xin = sin(-w*t); %Plotting the transformed and original signals hold 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.6 2) Computer 3) Printer Theory: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-1 y(k)=0; for l=1:i if (k-l+1>0) y(k)=y(k)+A(l)*B(k-l+1); else end end end; 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)
th
the vector y is of length m+n-1, where k 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
end end y(p) = sum; end t1 = 0:0.01:(Ly-1)*0.01; %Input Signal subplot(2,2,1); plot(t,x); title('Input Signal'); xlabel('Time'); ylabel('Amplitude of the signal'); %Impulse Response subplot(2,2,2); plot(t,h); title('Impulse Response'); xlabel('Time'); ylabel('Amplitude of the signal'); %Output of the LTI System subplot(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 and plot its Magnitude and Phase spectra. Hardware required/software required:1) MATLAB version 7.6 2) Computer 3) Printer Theory:- Fourier transform is divided into 2 parts • Continuous time Fourier transform This is applicable for aperiodic function and periodic functions
And the corresponding function is X(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 spectra And 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.6 2) Computer 3) Printer Theory:- A continuous time signal x(t) to be periodic if there is a positive non zero value of t for which
All
t
----- (1)
The fundamental period T0 of x (t) is the smallest positive value of T for which equation (1) is not 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 as fundamental period
wo=2π/To Where
are the complex Fourier Coefficients
Program Code: (Example)
t = 0:0.01:10; %Train of Pulses x = [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; end a(k+11) = sum; end for i=1:21 mag(i) = abs(a(i)); phase(i) = angle(a(i)); end k=-10:10; %Original Signal subplot(2,2,[1:2]); plot(t,x); title('Input Signal (A Pulse Train)'); xlabel('Time'); ylabel('Amplitude of the signal'); %Magnitude Spectra subplot(2,2,3); stem(k,mag); title('Magnitude Spectra'); xlabel('k \rightarrow'); ylabel('Magnitude'); %Phase Spectra subplot(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.6 2) Computer/Laptop 2) Printer Theory:- Inverse Fourier transform is used to convert a signal in frequency domain to a signal in time domain. If X(w) is the Fourier transform of a signal then, the original signal x(t) or inverse Fourier transform 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; end x(m) = sum; m=m+1; end w=-100:.1:100; t=0:.01:10; %given signal subplot(2,1,1); plot(w,X); title('Given signal in Frequency domain'); xlabel('Frequency \rightarrow'); ylabel('X(w)'); grid on; %signal in time domain subplot(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 Phase response of FIR system. Hardware/Software Required:1) MATLAB version 7.6 2) Computer 3) Printer Theory:- [h,p]=-freqz(ba,a,w) returns the frequency response vector h and the corresponding angular frequency vector for the digital filter whose transfer function is determined by the (real or complex) numerator and denominator polynomial represented by the vector b and a respectively. 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 system subplot(3,1,1); plot(h); grid on; xlabel('time'); ylabel('h[n]'); title('Impulse Response'); % plot of the magnitude of frequency respons e of the system subplot(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 system subplot(3,1,3) plot(w,angle(H)); grid on; title('plot of the magnitude response '); xlabel('w');
SIGNALS AND SYSTEMS LABORATORY EC-209
ylabel('
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 phase response of IIR system. Hardware/Software Required:1) MATLAB version 7.6 2) Computer 3) Printer Theory:- a system whose impulse response or no. of non zero values of the output is infinite is called 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 the system. Taking Fourier transform, of the three. We get X (w), Y(w) &h(w) Y (t)=x(t)*h(t) Taking Fourier transform Y(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 respons e of the system subplot(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 system subplot(2,1,2) plot(p); grid on; title('Phase response '); xlabel('w'); ylabel('
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.6 2) Computer 3) Printer THEORY:- A pole-zero plot shows the location in the complex plane of the poles and zeros of the 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 the plot by an X while the zeroes are indicated by a circle or O.A pole-zero plot can represent either a continuous-time (CT) or a discrete-time (DT) system. For a CT system, the plane in which the poles and zeros appear is the s plane of the Laplace transform. In this context, the parameter s represents the complex angular frequency, which is the domain of the CT transfer function. For a DT system, the plane is the z plane, where z represents the domain of the Ztransform. 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 the transfer function represented by numerator coefficients b and denominator coefficients a. The transfer 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 vector a in the current figure window. The symbol 'o' represents a zero and the symbol 'x' represents a pole. The plot includes the unit circle for reference. If z and p are arrays, zplane plots the poles and 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
SIGNALS AND SYSTEMS LABORATORY EC-209
Result :-Practical result is closely matched with experimental result.
SIGNALS AND SYSTEMS LABORATORY EC-209