JNTUA Simulation Lab Manual R20 - 1
JNTUA Simulation Lab Manual R20 - 1
me/jntua
Name:
H.T.No:
Year/Semester:_
Department of Electronics & Communication Engineering
www.android.universityupdates.in | www.universityupdates.in | https://telegram.me/jntua
PEO 1: To prepare the graduates to be able to plan, analyze and provide innovative ideas to
investigate complex engineering problems of industry in the field of Electronics and
Communication Engineering using contemporary design and simulation tools.
PEO-2: To provide students with solid fundamentals in core and multidisciplinary domain for
successful implementation of engineering products and also to pursue higher studies.
PEO-3: To inculcate learners with professional and ethical attitude, effective communication
skills, teamwork skills, and an ability to relate engineering issues to broader social context at
work place
www.android.universityupdates.in | www.universityupdates.in |
1. Write a program to generate various Signals and Sequences: Periodic and Aperiodic,
Unit Impulse, Unit Step, Square, Saw tooth, Triangular, Sinusoidal, Ramp, Sinc function.
2. Perform operations on Signals and Sequences: Addition, Multiplication,
Scaling, Shifting, Folding, Computation of Energy and Average Power.
3. Write a program to find the trigonometric & exponential Fourier series coefficients of
a rectangular periodic signal. Reconstruct the signal by combining the Fourier series
coefficients with appropriate weightages- Plot the discrete spectrum of the signal.
4. Write a program to find Fourier transform of a given signal. Plot its amplitude and
phase spectrum.
5. Write a program to convolve two discrete time sequences. Plot all the sequences.
6. Write a program to find autocorrelation and cross correlation of given sequences.
7. Write a program to verify Linearity and Time Invariance properties of a
given Continuous/Discrete System.
8. Write a program to generate discrete time sequence by sampling a continuous
time signal. Show that with sampling rates less than Nyquist rate, aliasing occurs
while reconstructing the signal.
9. Write a program to find magnitude and phase response of first order low pass and
high pass filter. Plot the responses in logarithmic scale.
10. Write a program to find response of a low pass filter and high pass filter, when a
speech signal is passed through these filters.
11. Write a program to generate Complex Gaussian noise and find its mean,
variance, Probability Density Function (PDF) and Power Spectral Density (PSD).
12. Generate a Random data (with bipolar) for a given data rate (say 10kbps). Plot the
same for a time period of 0.2 sec.
13. To plot pole-zero diagram in S-plane/Z-plane of given signal/sequence and verify
its stability.
Note: All the experiments are to be simulated using MATLAB or equivalent software.
www.android.universityupdates.in | www.universityupdates.in |
VEMU INSTITUTE OF
TECHNOLOGY::P.KOTHAKOTA NEAR
PAKALA, CHITTOOR-517112
(Approved by AICTE, New Delhi & Affiliated to JNTUA, Anantapur)
Department of Electronics &Communication Engineering
(20A04301P) SIMULATION LAB II B.Tech– I SEM
LIST OF EXPERIMENTS TO BE CONDUCTED
1. Generation of Various Signals and Sequences.
8. Sampling Theorem.
1. GIBB’S Phenomenon.
CONTENTS
8. Sampling Theorem
DO'S
1. Read and understand how to carry out experiment thoroughly before coming to
the Lab.
2. Students should come to the lab in-time
3. It is mandatory to come to lab in a formal dress (Shirts, Trousers, ID card, and
Shoes for Boys - Chudidhar for Girls). Strictly no Jeans for both Girls and Boys.
4. It is mandatory to come with observation book and lab record in which previous
experiment should be written in record and the present lab's experiment in
observation book
5. Observation book of the present lab experiment should be get corrected on the
same day and Record should be corrected on the next scheduled lab session.
6.Bring all the required stationery like graph sheets, pencil & eraser, different color pens
etc.
7. Any failure / malfunction of PC must be reported to the faculty.
8. After completing your lab session SHUTDOWN the Systems, TURNOFF the
power switches and arrange the chairs properly.
DON'Ts
1. Do not eat food, drink beverages or chew gum in the laboratory.
2. Late corners are not allowed to enter the Laboratory.
3. Don't talk aloud or crack jokes in Laboratory.
4. Do not open any irrelevant sites on computer.
5. Do not use a flash drive on computers.
6. Do not upload, delete or alter any software on the computer.
7. Do not remove anything from the computer Laboratory without permission.
www.android.universityupdates.in | www.universityupdates.in |
SCHEME OF EVALUATION
Marks Awarded
Total
S.No Program Date Record Obs. Viva Attd. 30(M)
(10M) (10M) (5M) (5M)
1. Generation of Various Signals and Sequences
2. Operations on Signals and Sequences
8. Sampling Theorem
SIMULATION II B.Tech I
INTRODUCTION TO MATLAB
INTRODUCTION:
IMPORTANCE OF MATLAB:
MATLAB DESKTOP LAYOUT: When you launch MATLAB for the first time, the
MATLAB desktop appears with a default layout. You can change the desktop
configuration to suits your need.
THE COMMAND WINDOW: It is the place where you enter all MATLAB commands
at the “command prompt”(>>).MATLAB executes the commands and display the result of
each operation performed.
SIMULATION II B.Tech I
THE COMMAND HISTORY WINDOW: All the commands entered recently at the
command prompt are stored in the “command History” window, for future use, until you
select and delete them purposefully.
THE CURRENT DIRECTORY WINDOW: It displays the list of all files and folders
under the current directory, which happens to be the ‘work’ sub-directory, by default,
under the MATLAB root directory.
1. Create a new file called a ‘.m’, into which the MATLAB commands, comments and
the data can be entered.
2. Edit all that is written into the file using the usual commands such as cut, copy, etc.,
3. Import data such as ASCII text or a huge matrix, from an external environment in to
the file.
4. Save the file in a chosen directory.
5. Debug the MATLAB commands by running the program either line in a step mode or
run a portion of the program by setting break points.
6. Open an existing .m file for a possible modification.
SIMULATION II B.Tech I
AIM: To write a MATLAB Program to generate Continuous Time Signals such as unit step saw
tooth, triangular, sinusoidal, ramp, and sinc function.
SOFTWARE REQURIED :
PROGRAM:-
clc;
clear all;
close
all;
t=-10:0.01:10;
L=length(t);
for i=1:L
%to generate unit Step and ramp
function if t(i)<0
x1(i)=0;
x2(i)=0;
else
x1(i)=1;
x2(i)=t(i);
end;
end;
%to generate sinusoidal function
f=0.1;
x3=sin(2*pi*f*t);
%to generate Triangular and Sawtooth
waveforms x4=sawtooth(t,0.5);
x5=sawtooth(t);
SIMULATION II B.Tech I
SIMULATION II B.Tech I
subplot(2,3,2);
plot(t,x2);
xlabel('t--->');ylabel('amp--->');
title('unit ramp');
subplot(2,3,3);
plot(t,x3);
xlabel('t--->');ylabel('amp--->');
title('sinusoidal');
subplot(2,3,4);
plot(t,x4);
xlabel('t--->');ylabel('amp--->');
title('triangular');
subplot(2,3,5);
plot(t,x5);
xlabel('t--->');ylabel('amp--->');
title('sawtooth');
subplot(2,3,6);
plot(t,x6);
xlabel('t--->');ylabel('amp--->');
title('sinc function');
OUTPUT WAVEFORMS:
RESULT:
Hence MATLAB program written and executed successfully to generate of continuous
time signals such as unit step, saw tooth, triangular, sinusoidal, and ramp and sinc function.
SIMULATION II B.Tech I
SOFTWARE REQURIED :
PROCEDURE:
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:
clc;
clear all;
close
all;
n=-10:1:10;
L=length(n);
for i=1:L
if n(i)==0
x1(i)=1;
else
x1(i)=0;
end;
if n(i)>=0
x2(i)=1;
x3(i)=n(i);
else
x2(i)=0;
x3(i)=0;
end;
end;
% to generate exponential
sequence a=0.85;
x4=a.^n;
% to generate sinusoidal sequence
f=0.1;
x5=sin(2*pi*f*n);
figure;
subplot(3,2,1);
stem(n,x1);
xlabel('time n---->');
ylabel('amplitude---->');
VEMU INSTITUTE OF TECHNOLOGY, DEPT OF Pa
www.android.universityupdates.in | www.universityupdates.in |
SIMULATION II B.Tech I
SIMULATION II B.Tech I
OUTPUT WAVEFORMS:-
SIMULATION II B.Tech I
RESULT:
Hence MATLAB program written and executed successfully to generate of discrete time
signals such as unit impulse, unit step, and unit ramp, exponential and sinusoidal signals.
CONCLUSION:
1.
2.
SIMULATION II B.Tech I
SOFTWARE REQURIED :
PROGRAM:
clc,
close all;
clear all;
t=0:0.001:1;
L=length(t);
f1=1;
f2=3;
x1=sin(2*pi*f1*t);
x2=sin(2*pi*f2*t);
figure(' Name ', ' operationd on signals ')
subplot(3,2,1);
plot(t,x1,'b',t,x2,'r');
xlabel('time t---->');
ylabel('amplitude---->');
title('the signals x1(t) and x2(t)');
x3=x1+x2;
subplot(3,2,2);
plot(t,x3);
xlabel('time t---->');
ylabel('amplitude---->');
title('the sum of x1(t) and x2(t)');
x4=x1.*x2;
subplot(3,2,3);
plot(t,x4); xlabel('time t---->');
ylabel('amplitude---->');
title('the multiplication of x1(t) and x2(t)');
a=2;
y1=a*x1;
SIMULATION II B.Tech I
subplot(3,2,4);
plot(t,y1);
xlabel('time t---->');
ylabel('amplitude---->');
title('the scaling of x1signal);
t=-1:0.001:0;
x5=sin(2*pi*f1*(-t));
x6=sin(2*pi*f2*(-t));
subplot(3,2,5);
plot(t,x5,'b',t,x6,'r');
xlabel('time t---->');
ylabel('amplitude---->');
title('the folding of x1(t)and x2(t)');
x7=[zeros(1,200),x2(1:(L-200))];
subplot(3,2,6);
plot(t,x7);
xlabel('time t---->');
ylabel('amplitude---->');
title('the shifting of x1(t)and x2(t)');
%program for Energy of a
signal t=0:pi:10*pi;
z2=cos(2*pi*50*t).^2;
E=sum(abs(z2).^2);disp('Energy of given signal is');E
% program for Power of a signal
P=(sum(abs(z2).^2))/length(z2);
disp('Power of given signal
is');P
OUTPUT WAVEFORMS:
Energy of given signal
is E = 4.0388
is P =0.3672
SIMULATION II B.Tech I
SIMULATION II B.Tech I
RESULT:
Hence the various operations on signal such as addition, multiplication, scaling ,shifting
and folding, computation of energy and average power using MATLAB program was completed
successfully.
SIMULATION II B.Tech I
SOFTWARE REQURIED :
PROGRAM:
clc;
clear all;
close
all;
s1=input('Enter the Sequence 1: '); %Both s1 and s2 sequences are same length
n=0:length(s1) -1;
s2=input('Enter the Sequence 2: ');
subplot(2,2,1); stem(n,s1); xlabel('samples'); ylabel('amplitude'); title('first sequence');
subplot(2,2,2);stem(n,s2); xlabel('samples'); ylabel('amplitude');
title('second sequence');
s3=s1+s2; % Sum
subplot(2,2,3);stem(n,s3); xlabel('samples'); ylabel('amplitude');
title('sum of the sequences');
s4=s1.*s2; % Multiplication
subplot(2,2,4);stem(n,s4); xlabel('samples'); ylabel('amplitude');
title('multiplication of sequences');
figure;
subplot(3,2,[1,2]); stem(n,s1); xlabel('samples'); ylabel('amplitude'); title('first sequence');
s5=3*s1 ;% Amplitude Scaling
s6=s1/3 ;% Signal attenuation
subplot(3,2,3) ; stem(n,s5) ; xlabel('samples'); ylabel('amplitude');
title('Amplitude Scaled');
subplot(3,2,4) ; stem(n,s6) ; xlabel('samples'); ylabel('amplitude');title('Attenuated ') ;
s7=upsample(s1,2); % Signal Exapansion
s8=downsample(s1,3); % Signal Compression
n1 = 0:length(s7)-1;
n2 = 0:length(s8)-1;
subplot(3,2,5) ; stem(n1,s7) ; xlabel('samples'); ylabel('amplitude'); title(' Enlarged ')
subplot(3,2,6) ; stem(n2,s8) ; xlabel('samples'); ylabel('amplitude');
title('Compressed ')
VEMU INSTITUTE OF TECHNOLOGY, DEPT OF Pa
www.android.universityupdates.in | www.universityupdates.in |
SIMULATION II B.Tech I
SIMULATION II B.Tech I
figure;
subplot(2,2,1); stem(n,s1); xlabel('samples'); ylabel('amplitude'); title('first sequence');
n3=n+2; % delaying by 2
n4=n-3; % advanced by 3
s9=fliplr(s1);
n5=fliplr(-n);
subplot(2,2,2) ; stem(n5,s9) ; xlabel('samples'); ylabel('amplitude');
title('time reversed Sequence');
subplot(2,2,3) ; stem(n3,s1) ; xlabel('samples'); ylabel('amplitude');
title('delayed Sequence');
subplot(2,2,4) ; stem(n4,s1) ; xlabel('samples'); ylabel('amplitude');
title('advanced Sequence');
%Energy and Average Power
E = sum(s1.^2);
disp('Energy of given signal
is');E P = sum(s1.^2)/length(s1);
disp('Power of given signal is');P
OUTPUT WAVEFORMS:
SIMULATION II B.Tech I
SIMULATION II B.Tech I
RESULT:
Hence the various operations on sequences such as addition, multiplication, scaling,shifting
and folding, computation of energy and average power using MATLAB program was completed
successfully.
CONCULSION:
1.
2.
SIMULATION II B.Tech I
AIM: To write a MATLAB program to find the trigonometric Fourier series coefficients of a
rectangular periodic signal. Reconstruct the signal by combining the Fourier series coefficients with
appropriate weightages and also plot the discrete spectrum of the signal.
SOFTWARE REQUIRED:
MATLAB (2019b 9.7version) Software
PROCEDURE:
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:
clc
clear all
close
all
%% generation of periodic signal (time period axis etc)
T = 4; %time period (can be user defined)
w = (2*pi)/T;
t = -1:0.01:1;
N = 10; %number of harmonics (can be user
defined) n=1:N; %discrete axis
%% signals - choose 1 and comment other!
y = @(t)square(w.*t);
%% computation of a0,an and bn i.e trigonometric coeffecients
a0 = (1/T)*integral(y,0,T,'ArrayValued',true);
w = (2*pi)/T;
n = 1:N;
mul = @(t)cos(n'*w.*t);
mul2 = @(t)sin(n'*w.*t);
sig1 = @(t)y(t).*mul(t);
sig2=@(t)y(t).*mul2(t);
a = (2/T).*integral(sig1,0,T,'ArrayValued',true); %integral function takes function handles only
b = (2/T).*integral(sig2,0,T,'ArrayValued',true);
fphas=angle(a);
fphas1=angle(b);
%% Reconstruction of trigonometric
F.S z1=0;
w = (2*pi)/T;
for k = 1:N
z1 = z1 + a(k)*cos(k*w.*t)+b(k)*sin(k*w.*t);
VEMU INSTITUTE OF TECHNOLOGY, DEPT OF Pa
www.android.universityupdates.in | www.universityupdates.in |
SIMULATION II B.Tech I
end
z = a0 + z1;
err = immse(y(t),z);
%% plot figures
figure('Name','F.S trigonometric Series and
reconstruction') subplot(3,2,1);
stem(n,a);
title('Magnitude of an');
xlabel('Discrete axis');
ylabel('Magnitude');
subplot(3,2,2);
stem(n,b);
title('Magnitude of
bn'); xlabel('Discrete
axis');
ylabel('Magnitude');
subplot(3,2,3)
stem(n,fphas);
title('Phase of an');
xlabel('Discrete axis');
ylabel('Phase');
subplot(3,2,4)
stem(n,fphas1);
title('Phase of bn');
xlabel('Discrete axis');
ylabel('Phase');
subplot(3,2,5);
plot(t,y(t),'linewidth',2);
title('Original signal');
xlabel('Time axis');
ylabel('Amplitude');
subplot(3,2,6);
plot(t,z,'linewidth',2);
title('reconstructed signal');
xlabel('Time axis');
ylabel('Amplitude');
SIMULATION II B.Tech I
SIMULATION II B.Tech I
OUTPUT WAVEFORMS:
RESULT:
Hence the trigonometric Fourier series coefficients of a rectangular periodic signal using
MATLAB program was completed successfully.
SIMULATION II B.Tech I
SOFTWARE REQUIRED:
MATLAB (2019b 9.7version) Software
PROCEDURE:
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For output see command window/figure window.
PROGRAM:
clc
clear all
close
all
%% generation of periodic sequence (time period axis etc)
T = 4; %time period (can be user defined)
w = (2*pi)/T;
t = -5:0.01:5;
N = 70; %number of harmonics (can be user
defined) n=1:N; %discrete axis
%% signals - choose 1 and comment other!
y = @(t)square(w.*t);
%% Calculation of Exponential Fourier Series Coefficients
w = (2*pi)/T;
n = 1:N;
C0 = (1/T).*integral(y,0,T,'ArrayValued',true);
mul = @(t)exp(-1j*n'*w.*t);
mul2 = @(t)exp(1j*n'*w.*t);
sig = @(t)y(t).*mul(t);
sig2 = @(t)y(t).*mul2(t);
Cn = (1/T).*integral(sig,0,T,'ArrayValued',true);
Cn_neg = (1/T).*integral(sig2,0,T,'ArrayValued',true);
fphas=angle(Cn);
fphas1=angle(Cn_neg);
%% reconstruction as per the series with doubling for complex values (amplitude)
w = (2*pi)/T;
z1 = 0;
for k = 1:N
z1 = z1 + Cn(k).*exp(1j*k*w.*t);
end
z_com = z1 + C0;
z_com = z_com*2;
SIMULATION II B.Tech I
SIMULATION II B.Tech I
SIMULATION II B.Tech I
OUTPUT WAVEFORMS:
RESULT: Hence the Exponential Fourier series coefficients of a rectangular Periodic signal using
MATLAB program was completed successfully.
CONCLUSION:
1.
2.
SIMULATION II B.Tech I
Exp: 4 Date:
AIM: To write a MATLAB program to find Fourier transform of the given signal and to plot its
magnitude and phase spectrum.
SOFTWARE REQURIED :
MATLAB (2019b 9.7version) Software
. PROCEDURE:
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:
clc; clear all; close all;
syms t s ;
syms w float;
f=3*exp(-t)*heaviside(t); % given function
F=fourier(f); % to find Fourier
Transform disp('the fourier transform of 3*exp(-t)*u(t)
=');
disp(F); % to display the result in the command
window w=-2*pi:pi/50:2*pi;
F1=subs(F,w); % substitute w in F
function Fmag=abs(F1); % to find
magnitude Fphas=angle(F1); % to find
phase subplot(2,1,1);
plot(w,Fmag);
xlabel('w---->');
ylabel('Magnitude- - ->');
title('Magnitude spectrum');
grid;
subplot(2,1,2);
plot(w,Fphas);
xlabel('w---->');
ylabel('Phase in radians--->');
title('Phase spectrum');
grid;
SIMULATION II B.Tech I
SIMULATION II B.Tech I
OUTPUT WAVEFORMS:
RESULT:
Hence Fourier transform of given signal was calculated using MATLAB program and also
plotted its magnitude and phase spectrum successfully .
Phase Spectrum
SIMULATION II B.Tech I
CONCLUSION:
1.
2.
SIMULATION II B.Tech I
Exp: 5 Date:
SOFTWARE REQURIED :
MATLAB (2019b 9.7version) Software
.
PROCEDURE:
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:
clc;
clear all;
close all;
n=0:8;
x1=1;
x2=0;
y1=x1.*(n>=0 & n<=2)+x2.*(n>=2 & n<=8);
subplot(2,2,1);
stem(n,y1);
axis([0 8 0 1.5]);
xlabel('time n---->');
ylabel('amplitude---->');
title('the sequence y1[n]')
y2=x1.*(n>=0 & n<=4)+x2.*(n>=4 & n<=8);
subplot(2,2,2);
stem(n,y2);
axis([0 8 0 1.5]);
xlabel('time n---->');
ylabel('amplitude---->');
title('the sequence y2[n]')
y=conv(y1,y2);
L=length(y);
n=0:L-1;
subplot(2,2,[3,4]);
stem(n,y);
axis([0 10 0 4]);
xlabel('time n---->');
ylabel('amplitude---->');
title('the convolution sequence of y1[n]&y2[n]');
SIMULATION II B.Tech I
OUTPUT WAVEFORMS:
RESULT:
Hence two discrete sequences convolved by using MATLAB program successfully and
plotted the sequences.
CONCULSION:
1.
2.
SIMULATION II B.Tech I
Exp: 6 Date:
AIM: To write a MATLAB program to compute autocorrelation and cross correlation between two
sequences and signals.
SOFTWARE REQURIED :
MATLAB (2019b 9.7version) Software
.PROCEDURE:
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:
clc; clear all; close all;
% discrete time sequences
x=input(' Enter the first sequence x[n]= ');
y=input('Enter the second sequence y[n]= ');
z1=conv(x,fliplr(x)); % Autocorrelation of x\
z2=conv(x,fliplr(y)); % cross-correlation of x and y
figure('Name','autocorrelation and cross correlation between two sequences ')
subplot(4,1,1);stem(x);ylabel ('Amplitude');xlabel ('n--');title ('x(n) Vs n');
subplot(4,1,2);stem(y);ylabel ('Amplitude');xlabel ('n---');title ('y(n) Vs n');
subplot(4,1,3);stem(z1);ylabel ('Amplitude');xlabel ('n---');
title ('Autocorrelation of x(n)');
subplot(4,1,4);stem(z2);ylabel ('Amplitude');xlabel ('n---');
title ('Cross correlation of x(n) and y(n)');
disp('Autocorrelation of x(n) is');
disp(z1)
disp('Crosscorelation of x(n) and y(n) is');
disp(z2)
% Continuous time signals
t=0:0.01:2;
x=sin(2*pi*t);
y=square(2*pi*3*t);
z1=conv(x,fliplr(x));
z2=conv(x,fliplr(y));
t1=linspace(0,2*max(t),2*length(t)-1);
figure('Name','autocorrelation and cross correlation between two signals ')
subplot(4,1,1); plot(t,x); title('signal 1');axis([0 2 -1.5 1.5])
subplot(4,1,2); plot(t,y); title('signal 2'); axis([0 2 -1.5 1.5])
subplot(4,1,3); plot(t1,z1); title('autocorrelation of signal 1'); axis([0 4 -110 110])
subplot(4,1,4); plot(t1,z2); title('crosscorrelationof signals'); axis([0 4 -30 30])
SIMULATION II B.Tech I
INPUT SEQUENCE:
Enter the first sequence x[n]= [1 2 3 4]
Enter the second sequence y[n]= [1 2 1 2]
Autocorrelation of x(n) is
4 11 20 30 20 11 4
SIMULATION II B.Tech I
RESULT:
Hence the auto correlation and cross correlation between sequences and signals were
executed by using MATLAB program successfully.
CONCULSION:
1.
2.
SIMULATION II B.Tech I
AIM: To write a MATLAB program to verify the given system is linear or non-linear.
SOFTWARE REQURIED :
MATLAB (2019b 9.7version) Software
PROCEDURE:
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:
clc; clear all; close all;
x1=input('enter the x1[n] sequence='); % [0 2 4 6]
x2=input('enter the x2[n] sequence='); % [3 5 -2 -
5] if length(x1)~=length(x2)
disp(' length of x2 must be equal to the length of x1');
return;
end;
h=input('enter the h[n] sequence=');% [-1 0 -3 -1 2 1]
a=input('enter the constant a= '); % 2
b=input('enter the constant b= '); % 3
y01=conv(a*x1,h);
y02=conv(b*x2,h);
y1=y01+y02;
x=a*x1+b*x2;
y2=conv(x,h);
L=length(x1)+length(h)-1;
n=0:L-1;
subplot(2,1,1);
stem(n,y1);
label('n --->'); label('amp---->');
title('sum of the individual response');
subplot(2,1,2);
stem(n,y2);
xlabel('n --->'); ylabel('amp---->');
title('total response');
if y1==y2
disp('the system is a Linear system');
else
disp('the system is a non-linear system');end;
SIMULATION II B.Tech I
INPUT SEQUENCE:
Enter the x1[n] sequence= [0 2 4 6]
Enter the x2[n] sequence= [3 5 -2 -5]
Enter the h[n] sequence= [-1 0 -3 -1 2 1]
Enter the constant a= 2 & enter the constant b=
3 The system is a linear system
OUTPUT WAVEFORMS:
RESULT:
Hence linear or non-linear property of discrete system was verified successfully by using
MATLAB Program.
SIMULATION II B.Tech I
AIM: To write a matlab program to verify the given system is Time –invariant or Time–variant.
SOFTWARE REQURIED :
MATLAB (2019b 9.7version) Software
PROCEDURE:
Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:
clc; clear all; close all;
x=input('enter the sequence x[n]='); %[0 2 3 1 -2 7 3]
h=input('enter the sequence h[n]='); %[4 -5 -11 -3 7 2 6 8 -15]
d=input('enter the positive number for delay d='); % 5
xdn=[zeros(1,d),x]; % delayed input
yn=conv(xdn,h); % output for delayed input
y=conv(x,h); % actual output
ydn=[zeros(1,d),y]; % delayed
output figure;
subplot(2,1,1);
stem(0:length(x)-
1,x);
xlabel('n ---->'),ylabel('amp --->');
title('the sequence x[n] ');
subplot(2,1,2);
stem(0:length(xdn)-1,xdn);
xlabel('n ---->'),ylabel('amp --->');
title('the delayed sequence of x[n] ');
figure;
subplot(2,1,1);
stem(0:length(yn)-
1,yn);
xlabel('n ---->'),ylabel('amp --->');
title('the response of the system to the delayed sequence of x[n] ');
subplot(2,1,2);
stem(0:length(ydn)-1,ydn);
xlabel('n ---->'),ylabel('amp --->');
title('the delayed output sequence ');
if yn==ydn
disp('the given system is a Time-invarient system');
else
disp('the given system is a Time-varient system');
end;
SIMULATION II B.Tech I
SIMULATION II B.Tech I
INPUT SEQUENCE:
Enter the sequence x[n] = [0 2 3 1 -2 7 3]
Enter the sequence h[n] = [4 -5 -11 -3 7 2 6 8 -15]
Enter the positive number for delay d=5
The given system is a Time-invariant system
OUTPUT WAVEFORMS:
SIMULATION II B.Tech I
RESULT:
Hence time invariant or time variant property of discrete system was verified
successfully by using MATLAB Program.
CONCULSION:
1.
2.
SIMULATION II B.Tech I
Exp: 8 Date:
SAMPLING THEOREM
AIM: To generate a discrete time sequence by sampling a continuous time signal using a
MATLAB Program.
SOFTWARE REQURIED :
MATLAB (2019b 9.7version) Software
.
PROCEDURE:
Open MATLAB Software
Open new M-file
Type the program
Save in current directory
Run the program
For the output see command window\ Figure window.
PROGRAM:
clc;
close all;
clear all;
f1=3;
f2=23;
t=-0.4:0.0001:0.4;
x=cos(2*pi*f1*t)+cos(2*pi*f2*t);
figure(1);
plot(t,x,'-.r');
xlabel('time-----');
ylabel('amp---');
title('The original signal');
%case 1:
(fs<2fm)
fs1=1.4*f2;
ts1=1/fs1;
n1=-0.4:ts1:0.4;
xs1=cos(2*pi*f1*n1)+cos(2*pi*f2*n1);
figure(2);
stem(n1,xs1);
hold on;
plot(t,x,'-.r');
hold off;
legend('fs<2fm');
%case 2:
(fs=2fm)
fs2=2*f2;
ts2=1/fs2;
n2=-0.4:ts2:0.4;
xs2=cos(2*pi*f1*n2)+cos(2*pi*f2*n2);
figure(3);
VEMU INSTITUTE OF TECHNOLOGY, DEPT OF Pa
www.android.universityupdates.in | www.universityupdates.in |
SIMULATION II B.Tech I
stem(n2,xs2);
SIMULATION II B.Tech I
hold on;
plot(t,x,'-.r');
hold off;
legend('fs=2fm');
%case 3:
(fs>2fm)
fs3=7*f2;
ts3=1/fs3;
n3=-0.4:ts3:0.4;
xs3=cos(2*pi*f1*n3)+cos(2*pi*f2*n3);
figure(4);
stem(n3,xs3);
hold on;
plot(t,x,'-.r');
hold off;
legend('fs>2fm');
OUTPUT WAVEFORMS:
SIMULATION II B.Tech I
SIMULATION II B.Tech I
SIMULATION II B.Tech I
RESULTS:-
Hence a discrete time sequence was generated by sampling a continuous time signal by using a
MATLAB Program successfully.
CONCULSION:
1.
2.
SIMULATION II B.Tech I
Exp: 9 Date:
IIR BUTTER WORTH LOW PASS & HIGH PASS FILTER
AIM: To write a MATLAB program to find magnitude and phase response of first order IIR Butter
worth low pass and high pass filter. Also plot the responses in logarithmic scale.
SOFTWARE REQUIRED:
MATLAB (2019b 9.7version) Software
PROCEDURE:
Open MATLAB Software
Open new M-file
Type the program
Save in current directory
Run the program
For the output see command window\ Figure window.
PROGRAM:
clc;
clear all;
close
all;
display('enter the iir filter design specifications');
rp=input('enter the pass band ripple:');
rs=input('enter the stop band ripple:');
wp=input('enter the pass band freq:');
ws=input('enter the stop band freq:');
fs=input('enter the sampling freq:');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs);
c=input('enter choice filter 1.lpf 2.hpf /n');
if(c==1)
display('frequency response of IIR lpf is:');
[b,a]=butter(n,wn,'low');
end
if(c==2)
display('freq response of IIR hpf IS:');
[b,a]=butter(n,wn,'high');
end
w=0:0.01:pi;
h=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
figure;
subplot(2,1,1);
plot(w/pi,m);
title('mignitude response of IIR filter is:');
xlabel('(a)normalized frequency-->');
ylabel('gain in db-->');
subplot(2,1,2);
VEMU INSTITUTE OF TECHNOLOGY, DEPT OF Pa
www.android.universityupdates.in | www.universityupdates.in |
SIMULATION II B.Tech I
SIMULATION II B.Tech I
plot(w/pi,an);
title('phase response of IIR filter is;');
xlabel('(b) normalized frequency-->');
ylabel('phase in radians-->');
OUTPUT WAVEFORMS:
enter the iir filter design
specifications enter the pass band
ripple:2
enter the stop band ripple:20
enter the pass band freq:1000
enter the stop band freq:2000
enter the sampling freq:5000
enter choice filter 1.lpf 2.hpf /n
LOWPASSFILTER
SIMULATION II B.Tech I
SIMULATION II B.Tech I
RESULTS: Hence magnitude and phase response of first order IIR Butter worth low pass and high
pass filter was plotted in logarithmic scale by using a MATLAB Program successfully.
CONCULSION:
1.
2.
1. Define filter?
2. Name different types of filters?
3. Define 3 db frequency?
4. Define Bandwidth?
5. Define pass band, stop band and transition band?
SIMULATION II B.Tech I
Exp: 10 Date:
SPEECH SIGNAL
AIM: To write a MATLAB program to find response of a low pass filter and high pass filter, when
a speech signal is passed through these filters.
SOFTWARE REQUIRED:
MATLAB (2019b 9.7version) Software
PROCEDURE:
Open MATALB
Open new M-file
Type the program
Save in current directory
Compile and run the program
For the output see the command window / figure window
PROGRAM:
clc;clear; close all;
load(fullfile(matlabroot,'examples','signal','strong.mat'))
% soundsc(her,fs), disp('press any key to continue')
% pause
% soundsc(him,fs)
disp('press any key to
continue')
soundsc(her,fs);pause,
x = her';
y=x+.25*rand(1,length(x));
z=y';soundsc(z,fs);pause,
lp=fir1(50,.35,'low');figure,freqz(lp)
lpf=filter(lp,[10 1],y);
soundsc(lpf',fs);pause
hp = fir1(50,.35,'high');figure,freqz(hp)
hpf=filter(hp,3,y);
soundsc(hpf',fs);
figure
subplot(4,1,1);plot(x),title('original "strong" ')
subplot(4,1,2);plot(z),title('noisy signal ')
subplot(4,1,3);plot(lpf'),title('LPF output ')
SIMULATION II B.Tech I
SIMULATION II B.Tech I
subplot(4,1,4);plot(hpf'),title('HPF output')
OUTPUT WAVEFORMS:
Speech Signal-Saying the Word-“Strong”
SIMULATION II B.Tech I
RESULT:
Hence the response of a low pass filter and high pass filter, when a speech signal is passed
through these filters was executed by using a MATLAB Program successfully.
CONCULSION:
1.
2.
SIMULATION II B.Tech I
Exp: 11 Date:
GAUSSIAN NOISE
AIM: To generate a Gaussian noise and to compute its Mean, Mean Square Value, Skew, Kurtosis,
Probability Distribution Function (PDF) and Power Spectral Density (PSD).
SOFTWARE REQURIED :
MATLAB (2019b 9.7version) Software
.
PROCEDURE:
Open MATLAB Software
Open new M-file
Type the program
Save in current directory
Run the program
For the output see command window\ Figure window.
PROGRAM:
clc; clear all; close
all; t=-10:0.01:10;
L=length(t);
n=randn(1,L);
subplot(3,1,1);
plot(t,n);
xlabel('t --->'),ylabel('amp---->');
title('normal randon function');
nmean=mean(n);
disp('mean=');disp(nmean);
nmeansquare=sum(n.^2)/length(n);
disp('mean square=');disp(nmeansquare);
nstd=std(n);
disp('std=');disp(nstd);
nvar=var(n);
disp('var=');disp(nvar);
nskew=skewness(n);
disp('skew=');disp(nskew);
nkurt=kurtosis(n);
disp('kurt=');disp(nkurt);
p=normpdf(n,nmean,nstd);
subplot(3,1,2);
stem(n,p)
legend('Histogram','Theoretical PDF');
xlabel('Bins'); ylabel('PDF f_x(x)');
title('Power Density function');
xdft=fft(n);
xpsd=10*log10(abs(fftshift(xdft)));
norm_freq=linspace(-0.5, 0.5,
length(n));
VEMU INSTITUTE OF TECHNOLOGY, DEPT OF Pa
www.android.universityupdates.in | www.universityupdates.in |
SIMULATION II B.Tech I
SIMULATION II B.Tech I
subplot(3,1,3), plot(norm_freq,xpsd);
xlabel('Bins'); ylabel('PSD f_x(x)');
title( );
OUTPUT WAVEFORMS:
mean=0.0472
mean square= 1.0345
std=1.0163
var= 1.0328
skew=0.0279
kurt=2.870
RESULTS: Hence Gaussian signal was generated and calculated the parameters such as Mean,
Mean Square Value, Skew, Kurtosis, PSD and Probability Distribution Function by using MATLAB
programming.
SIMULATION II B.Tech I
CONCULSION:
1.
2.
SIMULATION II B.Tech I
Exp: 12 Date:
AIM: To generate a random data (with bipolar) for a given data rate.
SOFTWARE REQUIRED:
MATLAB (2019b 9.7version) Software
PROCEDURE:
Open MATALB
Open new M-file
Type the program
Save in current directory
Compile and run the program
For the output see the command window / figure window
PROGRAM:
clc;
clear all;
close
all;
tic;h = randi([0 1],1,10);toc
disp('The random Binary Sequence
is:') disp(h)
clf;tic
n=1;
l=length(h);
h(l+1)=1;
while n<=length(h)-1;
t=n-1:0.001:n;
if h(n) == 0
if h(n+1)==0
y=-(t<n-0.5)-(t==n);
else
y=-(t<n-0.5)+(t==n);
end
d=plot(t,y);grid on;
title('Line code BIPOLAR RZ');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5 1.5]);
else
if h(n+1)==0
%y=(t>n-1)-2*(t==n);
y=(t<n-0.5)-1*(t==n);
else
%y=(t>n-1)+(t==n-1);
y=(t<n-0.5)+1*(t==n);
end
%y=(t>n-1)+(t==n-1);
SIMULATION II B.Tech I
SIMULATION II B.Tech I
d=plot(t,y);grid on;
title('Line code BIPOLAR RZ');
set(d,'LineWidth',2.5);
hold on;
axis([0 length(h)-1 -1.5 1.5]);
end
n=n+1;
%pause;
end
toc
OUTPUT WAVEFORMS:
Elapsed time is 0.000816 seconds.
The random Binary Sequence is:
0 1 0 0 0 0 1 1 1 0
Elapsed time is 1.010915 seconds.
RESULTS: Hence random data with bipolar signal was generated by using MATLAB
programming.
CONCULSION:
1.
2.
SIMULATION II B.Tech I
Exp: 13 Date:
POLES AND ZEROS IN S- PLANE
AIM: To write a MATLAB program to plot pole-zero diagram in S-plane/Z-plane of given
signal/sequence and verify its stability.
SOFTWARE REQUIRED:
MATLAB (2019b 9.7version) Software
PROCEDURE:
Open MATALB
Open new M-file
Type the program
Save in current directory
Compile and run the program
For the output see the command window / figure window
PROGRAM:
clc; clear all; close all;
num=input('enter the numerator polynomial vector\n'); % [1 -2 1]
den=input('enter the denominator polynomial vector\n'); % [1 6 11
6] H=tf(num,den)
[p z]=pzmap(H);
disp('zeros are at ');
disp(z);
disp('poles are at ');
disp(p);
pzmap(H);
if max(real(p))>=0
disp(' All the poles do not lie in the left half of S-plane ');
disp(' the given LTI systen is not a stable system ');
else
disp('All the poles lie in the left half of S-plane ');
disp(' the given LTI systen is a stable system ');
end;
OUTPUT WAVEFORMS:
Zeros are at
1 1
Poles are at
-3.0000 -2.0000 -1.0000
SIMULATION II B.Tech I
RESULTS: Hence pole- zero in diagram in S-plane of the given signal was plotted and also verified
its stability by using MATLAB.
CONCLUSION:
1.
2.
VIVA QUESTIONS:
1. Define Transfer Function or System Function?
2. Define Pole and Zero?
3. Define Stability Criteria in S-Plan and Z-Plan?
4. Why the System Stability depends only on Pole location?
5. What is marginally stable and Absolute Stable systems?
SIMULATION II B.Tech I
ADVANCED
EXPERIMENT
SIMULATION II B.Tech I
Exp: 14 Date:
GIBB’S PHENOMENON
AIM: To write a MATLAB program to verify the Gibbs phenomenon.
SOFTWARE REQUIRED:
MATLAB (2019b 9.7version) Software
PROCEDURE:
Open MATALB
Open new M-file
Type the program
Save in current directory
Compile and run the program
For the output see the command window / figure window
PROGRAM:
% Gibb's
phenomenon clc;
clear all;
close all;
t=linspace(-2,2,2000);
u=linspace(-2,2,2000);
sq=[zeros(1,500),2*ones(1,1000),zeros(1,500)]; k=2;
N=[1,3,7,19,49,70];
for n=1:6;
an=[]; for
m=1:N(n)
an=[an,2*k*sin(m*pi/2)/(m*pi)]; end;
fN=k/2;
for m=1:N(n)
fN=fN+an(m)*cos(m*pi*t/2); end;
nq=int2str(N(n)); subplot(3,2,n),plot(u,sq,'r');hold
on;
plot(t,fN); hold off; axis([-2 2 -0.5 2.5]);grid;
xlabel('Time'), ylabel('y_N(t)');title(['N= ',nq]); end;
SIMULATION II B.Tech I
SIMULATION II B.Tech I
OUTPUT WAVEFORMS:
CONCULSION:
1.
2.
SIMULATION II B.Tech I
Exp: 15 Date:
SPECTRAL ANALYSIS OF COMPOSITE
(ADDED & MULTIPLIED) SIGNALS
AIM: To write a MATLAB program to spectral analysis of Composite (Added & Multiplied )
Signal.
SOFTWARE REQUIRED:
MATLAB (2019b 9.7version) Software
PROCEDURE:
Open MATALB
Open new M-file
Type the program
Save in current directory
Compile and run the program
For the output see the command window / figure window
PROGRAM:
clc;
clear all;
close
all;
Fs=1000;
T=1/Fs;
L=1000;
t=(0:L-1)*T;
%First signal(x1)
x1=cos(2*pi*20*t);
subplot(3,3,1);
plot(t(1:100),x1(1:100));
xlabel('t--->');ylabel('amp--->');
title('sine waveform-1');
%F.T of first signal-Y
n=2^nextpow2(L);
dim=2;
Y=fft(x1,n,dim);
p2=abs(Y/L);
p1=p2(:,1:n/2+1);
p1(:,2:end-1)=2*p1(:,2:end-1);
subplot(3,3,2);
plot(0:(Fs/n):(Fs/2-Fs/n),p1(1:n/2));
xlim([0 100])
xlabel('f--->');ylabel('amp--->');
title('FT of sine waveform-1');
%Second signal(x2)
x2=cos(2*pi*100*t);
subplot(3,3,3);
plot(t(1:100),x2(1:100));
xlabel('t--->');ylabel('amp--->');
VEMU INSTITUTE OF TECHNOLOGY, DEPT OF Pa
www.android.universityupdates.in | www.universityupdates.in |
SIMULATION II B.Tech I
SIMULATION II B.Tech I
title('sine waveform-2');
%F.T of Second signal-Y1
Y1=fft(x2,n,dim);
p3=abs(Y1/L);
p4=p3(:,1:n/2+1);
p4(:,2:end-1)=2*p4(:,2:end-1);
subplot(3,3,4);
plot(0:(Fs/n):(Fs/2-Fs/n),p4(1:n/2));
xlim([0 300])
xlabel('f--->');ylabel('amp--->');
title('FT of sine waveform-2');
%Sum of two signals x3
x3=x1+x2;
subplot(3,3,5);
plot(t(1:100),x3(1:100));
xlabel('t--->');ylabel('amp--->');
title('addition if x1&x2');
%F.T of sum of two signals-
Y2 Y2=fft(x3,n,dim);
p5=abs(Y2/L);
p6=p5(:,1:n/2+1);
p6(:,2:end-1)=2*p6(:,2:end-1);
subplot(3,3,6);
plot(0:(Fs/n):(Fs/2-Fs/n),p6(1:n/2));
xlim([0 300])
xlabel('f--->');ylabel('amp--->');
title('FT of sine waveform-x3');
%Multiplication of two signals
x4 x4=x1.*x2;
subplot(3,3,7);
plot(t(1:100),x4(1:100));
xlabel('t--->');ylabel('amp--->');
title('Multiplication of x1&x2');
%F.T of Multiplication of two signals-Y3
Y3=fft(x4,n,dim);
p8=abs(Y3/L);
p9=p8(:,1:n/2+1);
p9(:,2:end-1)=2*p9(:,2:end-1);
subplot(3,3,[8,9]); plot(0:(Fs/n):
(Fs/2-Fs/n),p9(1:n/2)); xlim([0
300])
xlabel('f--->');ylabel('amp--->');
title('FT of sine waveform-x4');
SIMULATION II B.Tech I
20Hz,200Hz
SIMULATION II B.Tech I
RESULTS:
Hence spectral analysis of Composite (Added & Multiplied ) Signal using by MATLAB
program successfully.
CONCULSION:
1.
2.