SIMULATION
SIMULATION
STUDENT NAME
ROLL NUMBER
SECTION
SVR ENGINEERING COLLEGE
Approved by AICTE & Permanently Affiliated to JNTUA
Ayyalurmetta, Nandyal – 518503. Website: www.svrec.ac.in
DEPARTMENT OF
ELECTRONICS AND COMMUNICATION ENGINEERING
CERTIFICATE
Mr./Ms.___________________________________________ bearing
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 auto correlation 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
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.
ECE DEPT VISION & MISSION PEOs and PSOs
Vision
To produce highly skilled, creative and competitive Electronics and Communication Engineers to meet the
Mission
Impart core knowledge and necessary skills in Electronics and Communication Engineering
Inculcate critical thinking, ethics, lifelong learning and creativity needed for industry and society
Cultivate the students with all-round competencies, for career, higher education and self-employability
PEO1: Graduates apply their knowledge of mathematics and science to identify, analyze and solve
problems in the field of Electronics and develop sophisticated communication systems.
PEO2: Graduates embody a commitment to professional ethics, diversity and social awareness in
theirprofessional career.
PEO3: Graduates exhibit a desire for life-long learning through technical training and
professional activities.
PSO1: Apply the fundamental concepts of electronics and communication engineering to design a
variety of components and systems for applications including signal processing, image
processing, communication, networking, embedded systems, VLSI and control system
PSO2: Select and apply cutting-edge engineering hardware and software tools to solve complex
Electronics and Communication Engineering problems.
III. PROGRAMME OUTCOMES (PO’S)
1. While entering the Laboratory, the students should follow the dress code. (Wear shoes and
2. The students should bring their observation book, record, calculator, necessary stationery items
and graphsheets if any for the lab classes without which the students will not be allowed for doing
the experiment.
3. All the Equipment and components should be handled with utmost care. Any breakage or damage
will becharged.
4. If any damage or breakage is noticed, it should be reported to the concerned in charge immediately.
5. The theoretical calculations and the updated register values should be noted down in the
observation bookand should be corrected by the lab in-charge on the same day of the laboratory
session.
6. Each experiment should be written in the record note book only after getting signature from the lab
in-charge in the observation notebook.
7. Record book must be submitted in the successive lab session after completion of experiment.
Precautions.
I N D E X
Page Date of Date of Marks Signatur
Name of the Experiment
No. Obtained e oflab
Performed Submission incharge
1. Write a program to generate various
Signals and Sequences: Periodic and
Aperiodic, Unit Impulse, Unit Step,
15-21
Square, Saw tooth, Triangular, Sinusoidal,
Ramp, Sinc function.
Objective of Laboratory
The main objective of this lab is to learn MATLAB and know why it is an
indispensable tool, especially for electronics and communication engineer.
Day-to-day evaluation:
The concerned teachers have to do necessary corrections with explanations and evaluate each lab
experiment.
Concerned Lab Incharge should also enter the marks in index page of the record and observation
book & also at the end of each experiment with signature.
Internal Laboratory examination:
30 marks will be awarded for internal Lab exam, the division of the marks as given below:
3. Result : 6 Marks
Internal lab exam will be conducted by the in-charge Faculty member along with Associate
Faculty members
Evaluation Procedure for External Laboratory Examinations
This examination will be conducted by the teacher in-charge of the lab and another two faculty
members of the same department (who have more knowledge in the concern lab), recommended
by Head of the Department with the approval of Principal.
The maximum marks for this examination is 70.
The distribution of marks for the evaluation is as follows.
1. Matlab program : 25 Marks
2. Execution : 10 Marks
4. Result : 15 Marks
MATLAB INTRODUCTION:
MATLAB, which stands for Matrix Laboratory, is a state-of-the-art mathematical
software package, which is used extensively in both academia and industry. It is an interactive
program for numerical computation and data visualization, which along with its programming
capabilities provides a very useful tool for almost all areas of science and engineering. Unlike
other mathematical packages, such as MAPLE or MATHEMATICA, MATLAB cannot perform
symbolic manipulations without the use of additional Toolboxes. It remains however, one of the
leading software packages for numerical computation.
As you might guess from its name, MATLAB deals mainly with matrices. A scalar is a 1-
by-1 matrix and a row vector of length say 5, is a 1-by-5 matrix.. One of the many advantages of
MATLAB is the natural notation used. It looks a lot like the notation that you encounter in a
linear algebra. This makes the use of the program especially easy and it is what makes MATLAB
a natural choice for numerical computations. The purpose of this experiment is to familiarize
MATLAB, by introducing the basic features and commands of the program.
Operators:
1. + addition
2. -subtraction
3. * multiplication
4. ^ power
5. ' transpose
6. \ left division
7. / right division
Remember that the multiplication, power and division operators can be used in conjunction with
a period to specify an element-wise operation.
Built in Functions:
1. Scalar Functions:
Certain MATLAB functions are essentially used on scalars, but operate element-wise when
7. exp -exponential
13. floor -round towards negative infinity 14. ceil -round towards positive infinity
2. Vector Functions:
Other MATLAB functions operate essentially on vectors returning a scalar value. Some of
1. max largest component : get the row in which the maximum element lies
3. Matrix Functions:
Much of MATLAB’s power comes from its matrix functions. These can be further separated into
two sub-categories. The first one consists of convenient matrix building functions, some of
which are given below.
eg: diag([0.9092;0.5163;0.2661])
ans =
0.9092 0 0
0 0.5163 0
0 0 0.2661
Aim: Generate various signals and sequences (Periodic and aperiodic), such as Unit Impulse,
Unit Step, Square, Saw tooth, Triangular, Sinusoidal, Ramp, Sinc.
Software Required: Matlab software
Theory: If the amplitude of the signal is defined at every instant of time then it is called
continuous time signal. If the amplitude of the signal is defined at only at some instants of time
then it is called discrete time signal. If the signal repeats itself at regular intervals then it is called
periodic signal. Otherwise they are called aperiodic signals.
EX: ramp,Impulse,unit step, sinc- Aperiodic signals square,sawtooth,triangular sinusoidal –
periodic signals.
» plot(x,y)
It is good practice to label the axis on a graph and if applicable indicate what each axis
represents. This can be done with the xlabel and ylabel commands.
» xlabel('x')
» ylabel('y=cos(x)')
Inside parentheses, and enclosed within single quotes, we type the text that we wish to be
displayed along the x and y axis, respectively. We could even put a title on top using
» plot (x,y,’g’)
Where the third argument indicating the color, appears within single quotes. We could get a
dashed line instead of a solid one by typing
» plot (x,y,’--’)
or even a combination of line type and color, say a blue dotted line by typing
» plot (x,y,’b:’)
We can get both graphs on the same axis, distinguished by their line type, using
» plot(x,y,'r--',x,z,'b:')
When multiple curves appear on the same axis, it is a good idea to create a legend to label and
distinguish them. The command legend does exactly this.
» legend ('cos(x)','sin(x)')
The text that appears within single quotes as input to this command, represents the legend
labels. We must be consistent with the ordering of the two curves, so since in the plot command
we asked for cosine to be plotted before sine, we must do the same here.
At any point during a MATLAB session, you can obtain a hard copy of the current plot
by either issuing the command print at the MATLAB prompt, or by using the command menus
on the plot window. In addition, MATLAB plots can by copied and pasted (as pictures) in your
favorite word processor (such as Microsoft Word). This can be achieved using the Edit menu on
the figure window. Another nice feature that can be used in conjunction with plot is the
command grid, which places grid lines to the current axis (just like you have on graphing paper).
Type help grid for more information. Other commands for data visualization that exist in
MATLAB include subplot create an array of (tiled) plots in the same window log log plot using
log-log scales semi logx plot using log scale on the x-axis semi logy plot using log scale on the
y-axis
The Sinc Function
The sinc function computes the mathematical sinc function for an input vector or matrix x.
Viewed as a function of time, or space, the sinc function is the inverse Fourier transform of the
rectangular pulse in frequency centered at zero of width 2p and height
The sinc function has a value of 1 when x is equal to zero, and a value of for all other elements
of x.
% Generation of signals and sequences
clc;
clear all;
close all;
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%generation of unit impulse signal
t1=-1:0.01:1
y1=(t1==0);
subplot(2,2,1);
plot(t1,y1);
xlabel('time');
ylabel('amplitude');
title('unit impulse signal');
%generation of impulse sequence
subplot(2,2,2);
stem(t1,y1);
xlabel('n');
ylabel('amplitude');
xlabel('n');
ylabel('amplitude');
title('sawtooth wave sequence');
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%generation of triangular wave signal
y5=sawtooth(2*pi*50*t,.5);
figure;
subplot(2,2,1);
plot(t,y5);
axis([0 0.1 -2 2]);
xlabel('time');
ylabel('amplitude');
title(' triangular wave signal');
%generation of triangular wave sequence
subplot(2,2,2);
stem(t,y5);
axis([0 0.1 -2 2]);
xlabel('n');
ylabel('amplitude');
title('triangular wave sequence');
%generation of sinsoidal wave signal
y6=sin(2*pi*40*t);
subplot(2,2,3);
plot(t,y6);
axis([0 0.1 -2 2]);
xlabel('time');
ylabel('amplitude');
title(' sinsoidal wave signal');
%generation of sin wave sequence
subplot(2,2,4);
stem(t,y6);
axis([0 0.1 -2 2]);
xlabel('n');
ylabel('amplitude');
title('sin wave sequence');
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%generation of ramp signal
y7=t;
figure;
subplot(2,2,1);
plot(t,y7);
xlabel('time');
ylabel('amplitude');
title('ramp signal');
%generation of ramp sequence
subplot(2,2,2);
stem(t,y7);
xlabel('n');
ylabel('amplitude');
title('ramp sequence');
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%generation of sinc signal
t3=linspace(-5,5);
y8=sinc(t3);
subplot(2,2,3);
plot(t3,y8);
xlabel('time');
ylabel('amplitude');
title(' sinc signal');
%generation of sinc sequence
subplot(2,2,4);
stem(y8);
xlabel('n');
ylabel('amplitude');
title('sinc sequence');
Theory:
Signal Addition
Addition: any two signals can be added to form a third signal,
z (t) = x (t) + y (t)
Multiplication:
Multiplication of two signals can be obtained by multiplying their values at every instant. z
z(t) = x (t) y (t)
Time reversal/Folding:
Time reversal of a signal x(t) can be obtained by folding the signal about t=0.
Y(t)=y(-t)
Signal Amplification/Scaling : Y(n)=ax(n) if a < 1 attenuation
a >1 amplification
Time shifting: The time shifting of x(n) obtained by delay or advance the signal in time by
using y(n)=x(n+k)
If k is a positive number, y(n) shifted to the right i e the shifting delays the signal
If k is a negative number, y(n ) it gets shifted left. Signal Shifting advances the signal
Program :
clc;
clear all;
close all;
% generating two input signals
t=0:.01:1;
x1=sin(2*pi*4*t);
x2=sin(2*pi*8*t);
subplot(2,2,1);
plot(t,x1);
xlabel('time');
ylabel('amplitude');
title('input signal 1');
subplot(2,2,2);
plot(t,x2);
xlabel('time');
ylabel('amplitude');
title('input signal 2');
% addition of signals
y1=x1+x2;
subplot(2,2,3);
plot(t,y1);
xlabel('time');
ylabel('amplitude');
title('addition of two signals');
% multiplication of signals
y2=x1.*x2;
subplot(2,2,4);
plot(t,y2);
xlabel('time');
ylabel('amplitude');
title('multiplication of two signals');
% scaling of a signal1
A=2;
y3=A*x1;
figure;
subplot(2,2,1);
plot(t,x1);
xlabel('time');
ylabel('amplitude');
title('input signal')
subplot(2,2,2);
plot(t,y3);
xlabel('time');
ylabel('amplitude');
title('amplified input signal');
% folding of a signal1
h=length(x1);
nx=0:h-1;
subplot(2,2,3);
plot(nx,x1);
xlabel('nx');
ylabel('amplitude');
title('input signal')
y4=fliplr(x1);
nf=-fliplr(nx);
subplot(2,2,4);
plot(nf,y4);
xlabel('nf');
ylabel('amplitude');
title('folded signal');
%shifting of a signal 1
figure;
subplot(3,1,1);
plot(t,x1);
xlabel('time t');
ylabel('amplitude');
title('input signal');
subplot(3,1,2);
plot(t+2,x1);
xlabel('t+2');
ylabel('amplitude');
title('right shifted signal');
subplot(3,1,3);
plot(t-2,x1);
xlabel('t-2');
ylabel('amplitude');
title('left shifted signal');
%operations on sequences
n1=1:1:9;
s1=[1 2 3 0 5 8 0 2 4];
figure;
subplot(2,2,1);
stem(n1,s1);
xlabel('n1');
ylabel('amplitude');
title('input sequence1');
s2=[1 1 2 4 6 0 5 3 6];
subplot(2,2,2);
stem(n1,s2);
xlabel('n2');
ylabel('amplitude');
title('input sequence2');
% addition of sequences
s3=s1+s2;
subplot(2,2,3);
stem(n1,s3);
xlabel('n1');
ylabel('amplitude');
title('sum of two sequences');
% multiplication of sequences
s4=s1.*s2;
subplot(2,2,4);
stem(n1,s4);
xlabel('n1');
ylabel('amplitude');
title('product of two sequences');
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Output:
enter the input sequence[1 3 2 4 1]
energy of given sequence is
e1 = 31
energy of given signal is
e2 = 4.0388
power of given sequence is
p1 = 6.2000
power of given signal is
p2 = 0.3672
Theory: to compute the trigonometric fourier series coefficients of a periodic square wave time
signal that has a value of 2 from time 0 to 3 and a value of -12 from time 3 to 6. It then repeats
itself. I am trying to calculate in MATLAB the fourier series coefficients of this time signal and
am having trouble on where to begin.
subplot(2,1,1)
plot([-3 -2 -2 -1 -1 0 0 1 1 2 2 3],... % plot original y(t)
yt = c0*ones(size(t)); % initialize yt to c0
subplot(2,1,2)
plot([-3 -2 -2 -1 -1 0 0 1 1 2 2 3],... % plot original y(t)
[-1 -1 1 1 -1 -1 1 1 -1 -1 1 1], ':');
hold; % plot truncated trigonometric FS
plot(t,yt);
xlabel('t (seconds)'); ylabel('y(t)');
ttle = ['EE341.01: Truncated Trigonometric Fourier Series with N = ',...
num2str(N)];
title(ttle);
hold;
subplot(2,1,1)
stem(0,c0); % plot c0 at nwo = 0
hold;
for n = -N:2:N, % loop over series index n
cn = 2/(j*n*wo); % Fourier Series Coefficient
stem(n*wo,abs(cn)) % plot |cn| vs nwo
end
for n = -N+1:2:N-1, % loop over even series index n
cn = 0; % Fourier Series Coefficient
stem(n*wo,abs(cn)); % plot |cn| vs nwo
end
xlabel('w (rad/s)')
ylabel('|cn|')
ttle = ['EE341.01: Amplitude Spectrum with N = ',num2str(N)];
title(ttle);
grid;
hold;
subplot(2,1,2)
stem(0,angle(c0)*180/pi); % plot angle of c0 at nwo = 0
hold;
for n = -N:2:N, % loop over odd series index n
cn = 2/(j*n*wo); % Fourier Series Coefficient
stem(n*wo,angle(cn)*180/pi); % plot |cn| vs nwo
end
for n = -N+1:2:N-1, % loop over even series index n
cn = 0; % Fourier Series Coefficient
stem(n*wo,angle(cn)*180/pi); % plot |cn| vs nwo
end
xlabel('w (rad/s)')
ylabel('angle(cn) (degrees)')
ttle = ['EE341.01: Phase Spectrum with N = ',num2str(N)];
title(ttle);
grid;
hold;
Result: Trigonometric & exponential Fourier series coefficients of a rectangular periodic signals
are plotted.
Aim: To find the Fourier Transform of a given signal and plotting its magnitude and phase
spectrum.
Software Required: Matlab software
Theory:
Fourier Transform:
The Fourier transform as follows. Suppose that ƒ is a function which is zero outside of some
interval [−L/2, L/2]. Then for any T ≥ L we may expand ƒ in a Fourier series on the interval
[−T/2,T/2], where the "amount" of the wave e2πinx/T in the Fourier series of ƒ is given by By
definition Fourier Transform of signal f(t) is defined as
Program:
clc;
clear all;
close all;
fs=1000;
N=1024; % length of fft sequence
t=[0:N-1]*(1/fs);
% input signal
x=0.8*cos(2*pi*100*t);
subplot(3,1,1);
plot(t,x);
axis([0 0.05 -1 1]);
grid;
xlabel('t');
ylabel('amplitude');
title('input signal');
% Fourier transform of given signal
x1=fft(x);
% magnitude spectrum
k=0:N-1;
Xmag=abs(x1);
subplot(3,1,2);
plot(k,Xmag);
grid;
xlabel('t');
ylabel('amplitude');
title('magnitude of fft signal')
%phase spectrum
Xphase=angle(x1);
subplot(3,1,3);
plot(k,Xphase);
grid;
xlabel('t');
ylabel('angle');
title('phase of fft signal');
5. Write a program to convolve two discrete time sequences. Plot all the
sequences
Aim: Write the program for convolution between two signals and also between two
sequences.
Software Required: Matlab software
Theory:
Convolution involves the following operations.
1. Folding
2. Multiplication
3. Addition
4. Shifting
Convolution is an integral concatenation of two signals. It is used for the determination of the
output signal of a linear time-invariant system by convolving the input signal with the impulse
response of the system. Note that convolving two signals is equivalent to multiplying the Fourier
transform of the two signals.
Program:
clc;
close all;
clear all;
%program for convolution of two sequences
x=input('enter input sequence: ');
h=input('enter impulse response: ');
y=conv(x,h);
subplot(3,1,1);
stem(x);
xlabel('n');
ylabel('x(n)');
title('input sequence')
subplot(3,1,2);
stem(h);
xlabel('n');
ylabel('h(n)');
title('impulse response sequence')
subplot(3,1,3);
stem(y);
xlabel('n');
ylabel('y(n)');
title('linear convolution')
disp('linear convolution y=');
disp(y)
%program for signal convolution
t=0:0.1:10;
x1=sin(2*pi*t);
h1=cos(2*pi*t);
y1=conv(x1,h1);
figure;
subplot(3,1,1);
plot(x1);
xlabel('t');
ylabel('x(t)');
title('input signal')
subplot(3,1,2);
plot(h1);
xlabel('t');
ylabel('h(t)');
title('impulse response')
subplot(3,1,3);
plot(y1);
xlabel('n');
ylabel('y(n)');
title('linear convolution');
.
Output:
enter input sequence: [1 3 4 5]
enter impulse response: [2 1 4]
linear convolution y=
2 7 15 26 21 20
xlabel('n');
ylabel('z(n)');
title('auto correlation of input sequence');
% cross correlation between two signals
% generating two input signals
t=0:0.2:10;
x1=3*exp(-2*t);
h1=exp(t);
figure;
subplot(2,2,1);
plot(t,x1);
xlabel('t');
ylabel('x1(t)');
title('input signal');
subplot(2,2,2);
plot(t,h1);
xlabel('t');
ylabel('h1(t)');
title('impulse signal');
% cross correlation
subplot(2,2,3);
z1=xcorr(x1,h1);
plot(z1);
xlabel('t');
ylabel('z1(t)');
title('cross correlation ');
% auto correlation
subplot(2,2,4);
z2=xcorr(x1,x1);
plot(z2);
xlabel('t');
ylabel('z2(t)');
title('auto correlation ');
Result: Auto correlation and Cross correlation between signals and sequences is computed.
y2=x2.^2;
y3=x3.^2;
yt=a1*y1+a2*y2;
if y3==yt
disp('given system [y(n)=x(n).^2 ]is Linear');
else
disp('given system is [y(n)=x(n).^2 ]non Linear');
end
Output:
enter the scaling factor a1=3
enter the scaling factor a2=5
given system [y(n)=n.x(n)]is Linear
given system is [y(n)=x(n).^2 ]non Linear
Program (B) :
Output:
transformation of delay signal yd:
0 0 0 1 4 9 16 25 36 49 64 81
delay of transformation signal dy:
0 0 0 1 4 9 16 25 36 49 64 81
The maximum frequency component of g(t) is fm. To recover the signal g(t) exactly from its
samples it has to be sampled at a rate fs ≥ 2fm.
The minimum required sampling rate fs = 2fm is called ' Nyquist rate
Program:
clc;
clear all;
close all;
t=-10:.01:10;
T=4;
fm=1/T;
x=cos(2*pi*fm*t);
subplot(2,2,1);
plot(t,x);
xlabel('time');
ylabel('x(t)');
title('continous time signal');
grid;
n1=-4:1:4;
fs1=1.6*fm;
fs2=2*fm;
fs3=8*fm;
x1=cos(2*pi*fm/fs1*n1);
subplot(2,2,2);
stem(n1,x1);
xlabel('time');
ylabel('x(n)');
title('discrete time signal with fs<2fm');
hold on;
subplot(2,2,2);
plot(n1,x1);
grid;
n2=-5:1:5;
x2=cos(2*pi*fm/fs2*n2);
subplot(2,2,3);
stem(n2,x2);
xlabel('time');
ylabel('x(n)');
title('discrete time signal with fs=2fm');
hold on;
subplot(2,2,3);
plot(n2,x2)
grid;
n3=-20:1:20;
x3=cos(2*pi*fm/fs3*n3);
subplot(2,2,4);
stem(n3,x3);
xlabel('time');
ylabel('x(n)');
title('discrete time signal with fs>2fm')
hold on;
subplot(2,2,4);
plot(n3,x3)
grid;
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.
Aim: To find magnitude and phase response of first order low pass and high pass filter. Plot the
responses in logarithmic scale.
Theory: To get the phase response in the time domain you need to estimate the delay between
the input and the output at the test frequency and then convert to phase. For sure, taking the angle
of the RMS ratio will not yield that delay. If you really want to estimate the delay in the time
domain, there is a function called finddelay that may be of use.
However, the alternative approach is to work in the frequncy domain, i.e., use the ratio of the
frequency response of the output to the frequency resposne of the input to directly stimate the
magnitude and phase response of the system. The code that follows shows how to do that for a
simple low pass filter. Keep in mind, that any approach you use may begin to suffere as you test
frequency gets close to the Nyquist frequency. You can experiment with this code to see how
close you can get before this simple approach begins to break down.
Program :
f=1:15;
% second order filter with 10 Hz pass band
H = @(f,s) 1./(1./(2*pi*f).^2*s.^2 + 2./(2*pi*f)*s + 1);
H10 = @(s) H(10,s);
% magnitude estimation
magn = abs(H10(1j*2*pi*f));
% phase estimation
phase = rad2deg( angle(H10(1j*2*pi*f)) );
figure;
subplot(2,1,1);
semilogx(f,mag2db(magn));
title('Frequency response of the filter using abs(Out/Inp)')
xlabel('Frequency');
ylabel ('Change in output/input P-P' );
subplot(2,1,2);
semilogx(f,phase);
title('Phase response of the filter using angle(Out/Inp)')
xlabel('Frequency');
ylabel ('phase' );
% check against inbuilt functions
H_tf = @(f) tf(1,[1./(2*pi*f).^2 2./(2*pi*f) 1]);
figure;
bodeplot(H_tf(10),2*pi*f)
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.
Aim: To find response of a low pass filter and high pass filter, when a speech signal is passed
through these filters.
Theory:
y = lowpass(x,wpass) filters the input signal x using a lowpass filter with normalized passband
frequency wpass in units of π rad/sample. lowpass uses a minimum-order filter with a stopband
attenuation of 60 dB and compensates for the delay introduced by the filter. If x is a matrix, the function
filters each column independently.
y = lowpass(x,fpass,fs) specifies that x has been sampled at a rate of fs hertz. fpass is the
passband frequency of the filter in hertz.
y = lowpass(xt,fpass) lowpass-filters the data in timetable xt using a filter with a passband frequency
of fpass hertz. The function independently filters all variables in the timetable and all columns inside each
variable.
y = lowpass(___,Name,Value) specifies additional options for any of the previous syntaxes using name-
value pair arguments. You can change the stopband attenuation, the transition band steepness, and the
type of impulse response of the filter.
[y,d] = lowpass(___) also returns the digitalFilter object d used to filter the input.
lowpass(___) with no output arguments plots the input signal and overlays the filtered signal.
Program :
% Read standard sample tune that ships with MATLAB.
[dataIn, Fs] = audioread('guitartune.wav');
% Filter the signal
fc = 800; % Make higher to hear higher frequencies.
% Design a Butterworth filter.
[b, a] = butter(6,fc/(Fs/2));
freqz(b,a)
% Apply the Butterworth filter.
filteredSignal = filter(b, a, dataIn);
% Play the sound.
player = audioplayer(filteredSignal, Fs);
play(player);
Result: Response of a low pass filter and high pass filter, when a speech signal studied.
11 .Write a program to generate Complex Gaussian noise and find its mean,
variance, Probability Density Function (PDF) and Power Spectral Density
(PSD).
Aim: Write the program for generation of Gaussian noise and computation of its mean, mean
square value, standard deviation, variance, and skewness.
Software Required: Matlab software
Theory:
Gaussian noise is statistical noise that has a probability density function (abbreviated pdf) of
the normal distribution (also known as Gaussian distribution). In other words, the valuestha the
noise can take on are Gaussian-distributed. It is most commonly used as additive white noise to
yield additive white Gaussian noise (AWGN).Gaussian noise is properly defined as the noise
with a Gaussian amplitude distribution. says nothing of the correlation of the noise in time or of
the spectral density of the noise. Labeling Gaussian noise as 'white' describes the correlation of
the noise. It is necessary to use the term "white Gaussian noise" to be correct. Gaussian noise is
sometimes misunderstood to be white Gaussian noise, but this is not the case.
Program:
clc;
clear all;
close all;
%generates a set of 2000 samples of Gaussian distributed random numbers
x=randn(1,2000);
%plot the joint distribution of both the sets using dot.
subplot(211)
plot(x,'.');
title('scatter plot of gaussian distributed random numbers');
ymu=mean(x)
ymsq=sum(x.^2)/length(x)
ysigma=std(x)
yvar=var(x)
yskew=skewness(x)
p=normpdf(x,ymu,ysigma);
subplot(212);
stem(x,p);
title(' gaussian distribution');
Output:
ymu = 0.0403
ymsq = 0.9727
ysigma = 0.9859
yvar = 0.9720
yskew = 0.0049
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.
Aim: To Generate a Random data (with bipolar) for a given data rate (say 10kbps). Plot the same
for a time period of 0.2 sec.
Theory:
X = rand returns a single uniformly distributed random number in the interval (0,1).
X = rand(sz) returns an array of random numbers where size vector sz specifies size(X). For
example, rand([3 4]) returns a 3-by-4 matrix.
Program :
clc;
clear all;
a=-3
b=3
x=rand
c=a+(b-a)*x
y=c^2
z=y
for i=1:1000
x1=rand
c1=a+(b-a)*x1
y1=c1^2
if y1<z
z=y1
else
z;
end
end
z
Aim: Write the program for locating poles and zeros and plotting pole-zero maps in s-plane
and z-plane for the given transfer function.
Software Required: Matlab software
Theory:
Z-transforms
The Z-transform, like many other integral transforms, can be defined as either a one-sided or
two-sided transform.
Program
clc;
clear all;
close all;