0% found this document useful (0 votes)
9 views

lab2

The document outlines a series of experiments using MATLAB to generate discrete time signals, verify linear and circular convolution, and sum sinusoidal signals. Each experiment includes an aim, required equipment, theory, procedure, and MATLAB program code for implementation. The results demonstrate the successful execution of the programs and the generation of output waveforms.

Uploaded by

alekhyaprasad422
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

lab2

The document outlines a series of experiments using MATLAB to generate discrete time signals, verify linear and circular convolution, and sum sinusoidal signals. Each experiment includes an aim, required equipment, theory, procedure, and MATLAB program code for implementation. The results demonstrate the successful execution of the programs and the generation of output waveforms.

Uploaded by

alekhyaprasad422
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

EXPERIMENT NO: 1

GENERATION OF DISCRETE TIME SIGNALS


AIM:

To generate a discrete time signal sequence (Unit step, Unit ramp, Sine,
Cosine, Exponential, Unit impulse) using MATLAB function.

APPARATUS REQUIRED:

HARDWARE: Personal Computer.

SOFTWARE: MATLAB R2014a.

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.

Ramp signal: The ramp function is a unitary real function, easily computable as
the mean of the independent variable and its absolute value. This function is
applied in engineering. The name ramp function is derived from the
appearance of its graph.

r(t) = t when t≥0

= 0 else

Unit impulse signal: one of the more useful functions in the study of linear
systems is the “unit impulse function.” An ideal impulse function is a function
that is zero everywhere but at the origin, where it is infinitely high. However,
the area of the impulse is finite.
Y(t) = 1 when t=0

=0 otherwise

Unit step signal: the unit step function and the impulse function are
considered to be fundamental functions in engineering, and it is strongly
recommended that the reader becomes very familiar with both of these
functions.

u(t)= 0 if t<0

1 if t>0

½ if t=0

Sinc signal: there is a particular form that appears so frequently in


communications engineering, that we give it its own name. This function is
called the “sinc function. The sinc function is defines in the following
manner:

Sinc(x) = if x ≠ 0 and sinc(0) = 1

The value of sinc(x) is defined as 1 at x = 0, since

sinc(x) = 1

PROCEDURE:

1. Start the MATLAB program.


2. Open new M-file.
3. Type the program.
4. Save in current directory.
5. Compile and Run the program.
6. If any error occurs in the program correct the error and run it again.
7. For the Output see command window\Figure window.
8. Stop the program.
PROGRAM: (Generation of Discrete Time Signals)

%generation of sequences
clc;clear all;
close all;
N= input ('enter length of unit step sequence (N) =');
a=input('enter the scaling factor a=');
%generation unit step sequence
n=-N:1:N;
subplot (3,3,1);
y=[zeros(1,N),1,ones(1,N)];
stem (n, y);
xlabel ('time n');
ylabel ('ampliude in y');
title ('generating unit step signal');
%generation of unit ramp sequence
t=0:1: N;
subplot (3,3,2);
stem(t, t, 'r', '--');
hold on;
plot (t, t);
axis([-2 N -2 N]);
xlabel('time ');
ylabel('ampliude');
title('ramp signal');
%generation of sinusoidal sequence
t=0:0.05:N;
x=sin(2*pi*t);
subplot(3,3,3);
plot(t,x);
xlabel('time');
ylabel('amplitude');
title('analog sinusoidal signal');
subplot(3,3,4);
stem(t,x);
xlabel('time');
ylabel('amplitude');
title('discrete sinusoidal signal');
%generation of cosine sequence
t=0:0.05:N;
x=cos(2*pi*t);
subplot(3,3,5);
plot(t,x);
xlabel('time');
ylabel('amplitude');
title('analog sinusoidal signal');
subplot(3,3,6);
stem(t,x);
xlabel('time');
ylabel('amplitude');
title('discrete sinusoidal signal');
%generation of exponential sequence
t=0:1:N-1;
subplot(3,3,7);
y=exp(a*t);
stem(t,y);
xlabel('time');
ylabel('amplitude');
title('exponential sequence');
%generating of unit impulse sequence
n=-N:1:N;
subplot(3,3,8);
y=[zeros(1,N),1,zeros(1,N)];
stem(n,y);
xlabel('time n');
ylabel('ampliude in y');
title('generating impulse signal');
COMMAND WINDOW:
enter length of unit step sequence (N) =10
enter the scaling factor a=0.3
OUTPUT WAVEFORMS: (generation of discrete time signals)

generating unit step signal ramp signal analog sinusoidal signal


1 10 1

0.5
ampliude in y

amplitude
ampliude
5
0.5 0

-0.5
0
0 -1
-10 -5 0 5 10 -2 0 2 4 6 8 10 0 2 4 6 8 10
time n time time
discrete sinusoidal signal analog sinusoidal signal discrete sinusoidal signal
1 1 1

0.5 0.5 0.5


amplitude

amplitude

amplitude
0 0 0

-0.5 -0.5 -0.5

-1 -1 -1
0 2 4 6 8 10 0 2 4 6 8 10 0 2 4 6 8 10
time time time
exponential sequence generating impulse signal
15 1
ampliude in y

10
amplitude

0.5
5

0 0
0 2 4 6 8 10 -10 -5 0 5 10
time time n

RESULT:Thus the MATLAB programs for discrete time signal sequence (Unit
step, Unit ramp, Sine, Cosine, Exponential, Unit impulse) using MATLAB
function was written and the results were plotted.
EXPERIMENT NO:2

VERIFY LINEAR CONVOLUTION


AIM: To compute the responce of n discrete a LTI system with input sequence
x[n] and impulse responce h[n] by using linear convolution.

EQUIPMENT REQUIRED:

Operating System-Windows10

Constructer-Simulator

Software-CC Studio V3.1 MATLAB R2014a

THEORY:

Convolution is formal mathematical operation, just as multiplication, addition,


and integration. Addition takes two numbers and produces a third number,
while convolution takes two signals and produces a third signal. Convolution is
used the mathematics of many fields, such probability and statistics. In linear
systems, convolution is used to describe the relationship between three signals
of interest:the input signal, the impulse response, and the O signal.

Linear Convolution involves operations, 1.Folding, 2.Multiplication 3.Addition


and 4.Shifting. These operations represented by mathematical expression,

y[n] = x[k]h[n-k]

where x[k]= Input signal Samples

h[k]-Impulse response co-efficient.

y[n]= Convolution O.

PROCEDURE:

1.Open the MATLAB software.


2.Open new M-file.
3.Type the program.
4.Save in the current directory.
5.Compile and Run the program.
6.For the Output seecommand window/Figure window.
PROGRAM:( linear convolution without using conv function)
clc;
clear all;
clear all;
% program for convolution of two sequences
x=input('enter input sequence');
h=input('enter impulse responce');
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 responce');
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 responce');
subplot(3,1,3);
plot(y1);
xlabel('t');
ylabel('y(t)');
title('linear convolution');

Command window:
Enter the input sequence [1 2 3 4 5]
Enter the impulse responce [1 2 3 4 5]
X=12345
H=12345

Linear Convolution y= 1 5 2 3 9 9 0 2 5

OUTPUT WAVEFORMS:

input sequence
5
x(n)

0
1 1.5 2 2.5 3 3.5 4 4.5 5
n
impulse response
5
h(n)

0
1 1.5 2 2.5 3 3.5 4 4.5 5
n
linear convolution
50
y(n)

0
1 2 3 4 5 6 7 8 9
n
input signal
x(t) 1

-1
0 20 40 60 80 100 120
t
impulse responce
1
h(t)

-1
0 20 40 60 80 100 120
t
linear convolution
50
y(t)

-50
0 50 100 150 200 250
t

RESULT:Thus the MATLAB program for linear convolution was performed and
the Output was verified.
EXPERIMENT NO-3

VERIFY CIRCULAR CONVOLUTION


AIM: To compute Circular convolution of two input sequences x[n] and h[n].

EQUIPMENT REQUIRED:

Operating System-Windows10

Constructer-Simulator

Software- MATLAB R2014a

THEORY:

Circular convolution, also known as cyclic convolution, is a special case


of periodic convolution, which is the convolution of two periodic functions that
have the same period. Periodic convolution arises, for example, in the context
of the discrete-time Fourier transform (DTFT). In particular, the DTFT of the
product of two discrete sequences is the periodic convolution of the DTFTs of
the individual sequences.

And each DTFT is a periodic summation of a continuous Fourier


transform function (see DTFT § Definition). Although DTFTs are usually
continuous functions of frequency, the concepts of periodic and circular
convolution are also directly applicable to discrete sequences of data. In that
context, circular convolution plays an important role in maximizing the
efficiency of a certain kind of common filtering operation.

PROCEDURE:

1.Open the MATLAB software.


2.Open new M-file.
3.Type the program.
4.Save in the current directory.
5.Compile and Run the program.
6.For the Output seecommand window/Figure window.
PROGRAM:

clc;

clear all;

close all;

x=input('enter input sequence x(n):');

h=input('enter input sequence h(n):');

subplot(2,2,1);

stem(x);

xlabel('n value');

ylabel('amplitude');

title('X(n)');

subplot(2,2,2);

stem(h);

xlabel('n values');

ylabel('ámplitude');

title('h(n)');

N1=length(x);

N2=length(h);

N=max(N1,N2);

if(N1<N2);

x=[x,zeros(1,N-N1)];

end
if(N1>N2)

h1 [h,zeros(1,N-N2)];

end

y=zeros(1,N);

for m=0:N-1

for n=0:N-1

z=mod(m-n,N);

y(m+1)=y(m+1)+x(n+1).*h(z+1);

end

end

subplot(2,2,3);

stem(y);

xlabel('n values');

ylabel('samples');

title('circular convolution');

disp('y');

COMMAND WINDOW:
enter input sequence x(n):[1 1 2 2]

enter input sequence h(n):[1 2 3 4]


Ouput WAVEFORMS:

signal x(n)
3

0
0 0.5 1 1.5 2 2.5 3

signal h(n)
3

0
0 0.5 1 1.5 2 2.5 3

circular convoluted sequence


15

10
y(n)

0
0 0.5 1 1.5 2 2.5 3
n

RESULT:

Thus the MATLAB program for Circular convolution was performed and the
Output was verified.
EXPERIMENT NO-4

SUM OF SINUSOIDAL SIGNALS


AIM:To verify the Sum of Sinusoidal Signals using MATLAB.

EQUIPMENT REQUIRED:

Operating System-Windows10

Constructer-Simulator

Software- MATLAB R2014a

THEORY:

To generate fourier series of a signal by observing sum of sinusoidal


signals & observing gibbs phenomenon effect. Sinusoidal sequence:

X (n)= cos (w 0n+ n).

Where is the phase in radians. A MATLAB function cos (or sin) is used to
generate sinusoidal sequences. Signal addition: This is a sample-by-sample
addition given by

{X1 (n)}+ {x 2(n)} = {x 1(n) + x 2(n)) }

It is implemented in Matlab by the arithmetic operator’’+’’. However,


the lengths of x 1 (n) and x 2 (n) must be the same. If sequences are of
unequal lengths, or if the sample positions are different for equal length
sequences, then we cannot directly use the operator +. We have to first
augment x 1 (n) and x 2 (n) so that they have the same position vector n (and
hence the same length). This requires careful attention to MATLab's indexing
operations. In particular, logical operation of intersection "&"relational
operations like "=<" and "==" and the find function are required to make x 1(n)
and x 2 (n) of equal length.

PROCEDURE:

1.Open the MATLAB software.


2.Open new M-file.
3.Type the program.
4.Save in the current directory.
5.Compile and Run the program.
6.For the Output see command window/Figure window.

PROGRAM:
clc;
clear all;
close all;
t=0:0.001:0.1;
fl=50;
x1=2*pi*fl*t;
yl=sin(x1);
figure;
subplot (3,1,1);
plot (t,yl);
title('sin(x1)');
f2=100;
x2=2*pi*f2*t;
y2=sin(x2);
subplot(3,1,2);
plot(t,y2);
title('sin(x2)');
y=y1+y2;
subplot(3,1,3);
plot(t,y);
title('sinx1=sinx2')
OUTPUT WAVEFORMS:

RESULT:

Thus the MATLAB program for sum of two sinusodial signals was performed
and the Output was verified.
EXPERIMENT NO-5

VERIFY DISCRETE FOURIER TRANSFORM(DFT) AND INVERSE


DISCRETE FOURIER TRANSFORM(IDFT)
AIM:To verify Discrete Fourier Transform(DFT) AND Inverse Discrete Fourier
Transform(IDFT).

EQUIPMENT REQUIRED:

Operating System-Windows10

Constructer-Simulator

Software-CC Studio V3.1 MATLAB R2014a

THEORY:

In mathematics, the discrete Fourier transform (DFT) converts finite


sequence of equally-spaced samples of function into a same-length sequence
of equally-spaces samples of the discrete-time Fourier transform (DTFT), which
is a complex-valued function of frequency. the interval at which the DTFT is
sampled is the reciprocal of the duration of the input sequence. An inverse DFT
is a Fourier series, using the DTFT samples as coefficients complex sinusoids at
the corresponding DTFT frequencies. it has same sample-values as the original
input sequence. The DFT is therefore said to be a frequency domain
representation of the original input sequence. If the original sequence spans all
the non-zero values of a function, its DTFT is continuous (and periodic), and the
DFT provides discrete samples of one cycle. if the original sequence is one cycle
of a periodic function, the DFT provides all the non-zero values of one DTFT
cycle.

The DFT is the most important discrete transform, used to perform


Fourier analysis in many practical applications.in digital signal processing, the
function is any quantity or signal that varies over time, such as the pressure of
a sound wave, a radio signal, or daily temperature readings, sampled over a
finite time interval (often defined by a window function). In image processing,
the samples can be the values of pixels along a row or column of a raster
image. the DFT is also used to efficiently solve partial differential equations,
and to perform other operations such as convolutions or multiplying large
integers.

PROCEDURE:

1.Open the MATLAB software.


2.Open new M-file.
3.Type the program.
4.Save in the current directory.
5.Compile and Run the program.
6.For the Output see command window/Figure window.

PROGRAM:

clc;

clear all;

close all;

x=input('Please enter the sequence x(n)=');

N=input('please enter the length of the DFT N= ');

X=fft(x,N);

n=0:length(x)-1;

subplot(3,2,1);

stem(n,x);

title('input sequence');

subplot(3,2,2);

n=0:length(X)-1;

stem(n,X);

disp('DFT of input sequence is');

disp(X);
title('DFT');

subplot(3,2,3);

stem(n,abs(X));

title('magnitude spectrum');

Xr=ifft(x,N);

subplot(3,2,4);

stem(n,angle(X));

title('Phase spectrum');

Xr=ifft(x,N);

subplot(3,2,5);

stem(n,abs(Xr));

title('IDFT');

disp('IDFT of input sequence is ');

disp(Xr);

COMMAND WINDOW:

Please enter the sequence x(n)=[1 2 3 4 5 6 7 8 9]

please enter the length of the DFT N= 6

DFT of input sequence is

21.0000 + 0.0000i -3.0000 + 5.1962i -3.0000 + 1.7321i -3.0000 + 0.0000i -


3.0000 - 1.7321i -3.0000 - 5.1962i

IDFT of input sequence is

3.5000 + 0.0000i -0.5000 - 0.8660i -0.5000 - 0.2887i -0.5000 + 0.0000i -


0.5000 + 0.2887i -0.5000 + 0.8660i
OUTPUT WAVEFORMS:

input sequence DFT


10 50

5 0

0 -50
0 2 4 6 8 0 2 4 6
magnitude spectrum Phase spectrum
40 5

20 0

0 -5
0 2 4 6 0 2 4 6
IDFT
4

0
0 2 4 6

RESULT:

Thus the MATLAB program for Discrete Fourier Transform(DFT) and Inverse
Discrete Fourier Transform(IDFT) was performed and the was verified.
EXPERIMENT NO-6

FREQUENCY RESPONSE OF IIR LOW PASS BUTTERWORTH FILTER


AIM:To find the frequency response of IIR Low Pass Butterworth Filter using
MATLAB

EQUIPMENTS:

Operating System-Windows 10

Software-MATLAB R2014a

THEORY:

The Digital Filter Design problem involves the determination of a set of


filter coefficients to meet a set of design specifications. These specifications
typically consist of the width of the passband and the corresponding gain, the
width of the stopband(s) and the attenuation therein; the band edge
frequencies (which give an indication of the transition band) and the peak
ripple tolerable in the passband and stopband(s). The design of IIR filters is
closely related to the design of analog filters, which is a widely studied topic.
An analog filter is usually designed and a transformation iscarried out into the
digital domain. Two transformations exist the impulse invariant transformation
and the bilinear transformation.
PROCEDURE:

1. Start the MATLAB program.


2. Open new M-file.
3. Type the program.
4. Save in current directory.
5. Compile and run the program.
6. For the Output see command window\Figure window

PROGRAM:

clc;

clear all;

close all;

disp('enter the IIR filter design specifications');


rp=input('enter the passband ripple ');

rs=input('enter the stop band ripple ');

wp=input('enter the passband frequency ');

ws=input('enter the stopband frequeny ');

fs=input('enter the sampling freq ');

w1=2*wp/fs;%normalised pass band frequency

w2=2*ws/fs;%normalised stop band frequency

[n,wn]=buttord(w1,w2,rp,rs,'s');%find the order n and cutoff frequency

disp('frequency response of butterworth IIR LPF is');

[b,a]=butter(n,wn);

[H,w]=freqz(b,a,512,fs);

mag=20*log10(abs(H));

phase=angle(H);

subplot(2,1,1);

plot(w,mag);

grid on;

ylabel('magnitude in db');

xlabel('normalized frequency in hz');

title('magnitude response of the desired butterworth LPF');

subplot(2,1,2);

plot(w,phase);

grid on;

xlabel('(b)normalised frequency in hz');


ylabel('phase in radians');

title('phase response of the desired butterworth LPF');

COMMAND WINDOW:

enter the IIR filter design specifications

enter the passband ripple 0.15

enter the stop band ripple 60

enter the passband frequency 1500

enter the stopband frequeny 3000

enter the sampling freq 7000

OUTPUT WAVEFORM: Frequency response of Butterworth IIR LPF is

magnitude response of the desired butterworth LPF


200
magnitude in db

-200

-400
0 500 1000 1500 2000 2500 3000 3500
normalized frequency in hz
phase response of the desired butterworth LPF
4
phase in radians

-2

-4
0 500 1000 1500 2000 2500 3000 3500
(b)normalised frequency in hz

RESULT:

Thus the MATLAB program to find the frequency response of the IIR low pass
Butterworth filter was performed and the Output was verified.
EXPERIMENT NO-7

FREQUENCY RESPONSE OF IIR HIGH PASS BUTTERWORTH FILTER


AIM:To find the frequency response of IIR High Pass Butterworth Filter using
MATLAB.

EQUIPMENTS:

Operating System-Windows 10

Software-MATLAB R2014a

THEORY:

The Digital Filter Design problem involves the determination of a set of


filter coefficients to meet a set of design specifications. These specifications
typically consist of the width of the passband and the corresponding gain, the
width of the stopband(s) and the attenuation therein; the band edge
frequencies (which give an indication of the transition band) and the peak
ripple tolerable in the passband and stopband(s). The design of IIR filters is
closely related to the design of analog filters, which is a widely studied topic.
An analog filter is usually designed and a transformation is carried out into the
digital domain. Two transformations exist the impulse invariant transformation
and the bilinear transformation.

PROCEDURE:

1. Start the MATLAB program.


2. Open new M-file.
3. Type the program.
4. Save in current directory.
5. Compile and run the program.
6. For the Output see command window\Figure window

PROGRAM:

clc;

clear all;
close all;

disp('enter the IIR filter design specifications');

rp=input('enter the passband ripple ');

rs=input('enter the stop band ripple ');

wp=input('enter the passband frequency ');

ws=input('enter the stopband frequeny ');

fs=input('enter the sampling freq ');

w1=2*wp/fs;%normalised pass band frequency

w2=2*ws/fs;%normalised stop band frequency

[n,wn]=buttord(w1,w2,rp,rs);%find the order n and cutoff frequency

disp('frequency response of butterworth IIR HPF is');

[b,a]=butter(n,wn,'high');

[H,w]=freqz(b,a,512,fs);

mag=20*log10(abs(H));

phase=angle(H);

subplot(2,1,1);

plot(w,mag);

grid on;

ylabel('magnitude in db');

xlabel('normalized frequency in hz');

title('magnitude response of the desired butterworth HPF');

subplot(2,1,2);

plot(w,phase);
grid on;

xlabel('(b)normalised frequency in hz');

ylabel('phase in radians');

title('phase response of the desired butterworth HPF');

COMMAND WINDOW:

enter the IIR filter design specifications

enter the passband ripple 0.15

enter the stop band ripple 60

enter the passband frequency 1500

enter the stopband frequeny 3000

enter the sampling freq 7000

OUTPUT WAVEFORMS:Frequency response of Butterworth IIR HPF is:

magnitude response of the desired butterworth HPF


200
magnitude in db

-200

-400
0 500 1000 1500 2000 2500 3000 3500
normalized frequency in hz
phase response of the desired butterworth HPF
4
phase in radians

-2

-4
0 500 1000 1500 2000 2500 3000 3500
(b)normalised frequency in hz
RESULT:

Thus the MATLAB program to find the frequency response of the IIR high pass
Butterworth filter was performed and the Output was verified.
EXPERIMENT-8

FREQUENCY RESPONSE OF IIR LOW PASS CHEBYSHEV FILTER


AIM:To find the frequency response of IIR Low Pass Chebyshev Filter using
MATLAB

EQUIPMENTS:

Operating System-Windows 10

Software-MATLAB R2014a

THEORY:

The Digital Filter Design problem involves the determination of a set of


filter coefficients to meet a set of design specifications. These specifications
typically consist of the width of the passband and the corresponding gain, the
width of the stopband(s) and the attenuation therein; the band edge
frequencies (which give an indication of the transition band) and the peak
ripple tolerable in the passband and stopband(s). The design of IIR filters is
closely related to the design of analog filters, which is a widely studied topic.
An analog filter is usually designed and a transformation iscarried out into the
digital domain. Two transformations exist the impulse invariant transformation
and the bilinear transformation.

PROCEDURE:

1. Start the MATLAB program.


2. Open new M-file.
3. Type the program.
4. Save in current directory.
5. Compile and run the program.
6. For the Output see command window\Figure window

PROGRAM:

clc;

clear all;
close all;

disp('enter the IIR filter design specifications');

rp=input('enter the passband ripple ');

rs=input('enter the stop band ripple ');

wp=input('enter the passband frequency ');

ws=input('enter the stopband frequeny ');

fs=input('enter the sampling freq ');

w1=2*wp/fs;%normalised pass band frequency

w2=2*ws/fs;%normalised stop band frequency

[n,wn]=cheb1ord(w1,w2,rp,rs);%find the order n and cutoff frequency

disp('frequency response of chebyshev IIR LPF is');

[b,a]=cheby1(n,0.5,wn);

[H,w]=freqz(b,a,512,fs);

mag=20*log10(abs(H));

phase=angle(H);

subplot(2,1,1);

plot(w,mag);

grid on;

ylabel('magnitude in db');

xlabel('normalized frequency in hz');

title('magnitude response of the desired chebyshev LPF');

subplot(2,1,2);

plot(w,phase);
grid on;

xlabel('(b)normalised frequency in hz');

ylabel('phase in radians');

title('phase response of the desired chebyshev LPF');

COMMAND WINDOW:

enter the IIR filter design specifications

enter the passband ripple 0.15

enter the stop band ripple 60

enter the passband frequency 1500

enter the stopband frequeny 3000

enter the sampling freq 7000

OUTPUT WAVEFORMS: Frequency response of Chebyshev IIR LPF is:

magnitude response of the desired chebyshev LPF


0
magnitude in db

-100

-200

-300
0 500 1000 1500 2000 2500 3000 3500
normalized frequency in hz
phase response of the desired chebyshev LPF
4
phase in radians

-2

-4
0 500 1000 1500 2000 2500 3000 3500
(b)normalised frequency in hz
RESULT:Thus the MATLAB program to find the frequency response of the IIR
low pass Chebyshev filter was performed and the Output was verified.
EXPERIMENT-9

FREQUENCY RESPONSE OF IIR HIGH PASS CHEBYSHEV FILTER


AIM:To find the frequency response of IIR High Pass Chebyshev Filter using
MATLAB

EQUIPMENTS:

Operating System-Windows 10

Software-MATLAB R2014a

THEORY:

The Digital Filter Design problem involves the determination of a set of


filter coefficients to meet a set of design specifications. These specifications
typically consist of the width of the passband and the corresponding gain, the
width of the stopband(s) and the attenuation therein; the band edge
frequencies (which give an indication of the transition band) and the peak
ripple tolerable in the passband and stopband(s). The design of IIR filters is
closely related to the design of analog filters, which is a widely studied topic.
An analog filter is usually designed and a transformation iscarried out into the
digital domain. Two transformations exist the impulse invariant transformation
and the bilinear transformation.

PROCEDURE:

1. Start the MATLAB program.


2. Open new M-file.
3. Type the program.
4. Save in current directory.
5. Compile and run the program.
6. For the Output see command window\Figure window

PROGRAM:

clc;clear all;

close all;
disp('enter the IIR filter design specifications');

rp=input('enter the passband ripple ');

rs=input('enter the stop band ripple ');

wp=input('enter the passband frequency ');

ws=input('enter the stopband frequeny ');

fs=input('enter the sampling freq ');

w1=2*wp/fs;%normalised pass band frequency

w2=2*ws/fs;%normalised stop band frequency

[n,wn]=cheb1ord(w1,w2,rp,rs);%find the order n and cutoff frequency

disp('frequency response of chebyshev IIR HPF is');

[b,a]=cheby1(n,0.5,wn,'high');

[H,w]=freqz(b,a,512,fs);

mag=20*log10(abs(H));

phase=angle(H);

subplot(2,1,1);

plot(w,mag);

grid on;

ylabel('magnitude in db');

xlabel('normalized frequency in hz');

title('magnitude response of the desired chebyshev HPF');

subplot(2,1,2);

plot(w,phase);

grid on;
xlabel('(b)normalised frequency in hz');

ylabel('phase in radians');

title('phase response of the desired chebyshev HPF');

COMMAND WINDOW:

enter the IIR filter design specifications

enter the passband ripple 0.15

enter the stop band ripple 60

enter the passband frequency 1500

enter the stopband frequeny 3000

enter the sampling freq 7000

OUTPUT WAVEFORMS: Frequency response of Chebyshev IIR HPF is

magnitude response of the desired chebyshev HPF


0
magnitude in db

-100

-200

-300

-400
0 500 1000 1500 2000 2500 3000 3500
normalized frequency in hz
phase response of the desired chebyshev HPF
4
phase in radians

-2

-4
0 500 1000 1500 2000 2500 3000 3500
(b)normalised frequency in hz

RESULT: Thus the MATLAB program to find the frequency response of the
IIRhigh pass Chebyshev filter was performed and the Output was verified.
EXPERIMENT-10

FREQUENCY RESPONSE OF FIR LOW PASS FILTER USING


RECTANGULAR WINDOW
AIM:To find the frequency response of FIR Low Pass Filter using Rectangular
Window.

EQUIPMENTS:

Operating System-Windows 10

Software-MATLAB R2014a

THEORY:

FIR filters are digital filters with finite impulse response. They are also
known as non recursive digital filters as they do not have the feedback. An FIR
filter has two important advantages over an IIR design: □ Firstly, there is no
feedback loop in the structure of an FIR filter. Due to not having a feedback
loop, an FIR filter is inherently stable. Meanwhile, for an IIR filter, we need to
check the stability. Secondly, an FIR filter can provide a linear-phase response.

Matched filters perform a cross correlation between the input signal and
a known pulse-shape. The FIR convolution is a cross-correlation between the
input signal and a time-reversed copy of the impulse-response. Therefore, the
matched-filter's impulse response is "designed" by sampling the known pulse
shape and using those samples in reverse order as the coefficients of the filter.

PROCEDURE:

1. Start the MATLAB program.


2. Open new M-file.
3. Type the program.
4. Save in current directory.
5. Compile and run the program.
6. For the Output see command window\Figure window

PROGRAM:

clc;clear all;
close all;

rp=input('enter the passband ripple: ');

rs=input('enter the stop band ripple : ');

fp=input('enter the passband frequency: ');

fs=input('enter the stopband frequeny: ');

f=input('enter the sampling freq ');

wp=2*fp/f;%normalised pass band frequency

ws=2*fs/f;%normalised stop band frequency

num=-20*log10(sqrt(rp*rs));

dem=14.6*(fs-fp)/f;

n=ceil(num/dem);

n1=n+1;

if(rem(n,2)~=0);

n1=n;

n=n-1;end

y=boxcar(n1);

b=fir1(n,wp,y);

[h,om]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(2,1,1);

plot(om/pi,m);

xlabel('frequency');

ylabel('gain');
title('rectangular window for low pass filter magnitude response');

an=angle(h);

subplot(2,1,2);

plot(om/pi,an);

xlabel('frequency');

ylabel('phase');

title('rectangular window for low pass filter phase response');

COMMAND WINDOW:

enter the passband ripple: 0.45

enter the stop band ripple: 0.56

enter the passband frequency : 125

enter the stopband frequeny: 150

enter the sampling freq : 1000

OUTPUT WAVEFORMS:
rectangular window for low pass filter magnitude response
50

0
gain

-50

-100
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
frequency
rectangular window for low pass filter phase response
4

2
phase

-2

-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
frequency

RESULT:Thus the MATLAB program to find the frequency response of the FIR
low pass filter using rectangular window was performed and the Output was
verified.
EXPERIMENT-11

FREQUENCY RESPONSE OF FIR LOW PASS FILTER USING


TRIANGULAR WINDOW
AIM:To find the frequency response of FIR Low Pass Filter using Triangular
Window.

EQUIPMENTS:

Operating System-Windows 10

Software-MATLAB R2014a

THEORY:

A linear-phase is required throughout the passband of the filter to


preserve the shape of the given signal in the passband. A causal IIR filter
cannot give linear-phase characteristics and only special types of FIR filters that
exhibit center symmetry in its impulse response give the linear-space. A Finite
Impulse Response (FIR) filter is a discrete linear time-invariant system whose O
is based on the weighted summation of a finite number of past inputs. A zero-

phase frequency response of a ideal filter is given as

Hence time domain impulse response is

So the impulse response is doubly infinite, not absolutely summable, and


therefore unrealizable. By setting all impulse response coefficient outside the
range equal to zero, we arrival at a finite-length non causal approximation of
lengthwhich when shifted to the right yield the coefficients of a causal FIR
lowpass filter.

PROCEDURE:

1. Start the MATLAB program.


2. Open new M-file.
3. Type the program.
4. Save in current directory.
5. Compile and run the program.
6. For the Output see command window\Figure window

PROGRAM:

clc;

clear all;

close all;

rp=input('enter the passband ripple ');

rs=input('enter the stop band ripple ');

fp=input('enter the passband frequency ');

fs=input('enter the stopband frequeny ');

f=input('enter the sampling freq ');

wp=2*fp/f;

ws=2*fs/f;

num=-20*log10(sqrt(rp*rs));

dem=14.6*(fs-fp)/f;

n=ceil(num/dem);

n1=n+1;
if(rem(n,2)~=0);

n1=n;

n=n-1;

end

y=triang(n1);

b=fir1(n,wp,y);

[h,om]=freqz(b,1,256);

m=20*log10(abs(h));

subplot(2,1,1);

plot(om/pi,m);

xlabel('frequency');

ylabel('gain');

title('Triangular window for low pass filter magnitude response');

an=angle(h);

subplot(2,1,2);

plot(om/pi,an);

xlabel('frequency');

ylabel('phase');

title('Triangular window for low pass filter phase response');

COMMAND WINDOW:

enter the passband ripple: 0.45

enter the stop band ripple: 0.56

enter the pass band frequency: 125


enter the stop band frequenc : 150

enter the sampling frequency: 1000

OUTPUT WAVEFORMS:

Triangular window for low pass filter magnitude response


20

0
gain

-20

-40
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
frequency
Triangular window for low pass filter phase response
4

2
phase

-2

-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
frequency

RESULT:Thus the MATLAB program to find the frequency response of the IIR
low pass filter using triangular window was performed and the Output was
verified.
EXPERIMENT-12

N-POINT FFT ALGORITHM


AIM:To implementation of N-Point Fast Fourier Transform.

EQUIPMENTS:

Operating System-Windows 10

Software-MATLAB R2014a

THEORY:

The Fast Fourier Transform is useful to map the time-domain sequence into a
continuous function of a frequency variable. The FFT of a sequence {x(n)} of
length N is given by a complex-valued sequence X(k).

The above equation is the mathematical representation of the DFT. As the


number of computations involved in transforming a N point time domain signal
into its corresponding frequency domain signal was found to be N2 complex
multiplications, an alternative algorithm involving lesser number of

computations is opted. When the sequence x(n) is divided into 2 sequences


and the DFT performed separately, the resulting number of computations
would be N2/2 .
PROCEDURE:

1. Start the MATLAB program.


2. Open new M-file.
3. Type the program.
4. Save in current directory.
5. Compile and run the program.
6. For the Output see command window\Figure window

PROGRAM:

clc;clear all;

close all;

tic;

x=input('enter the sequence');

n=input('enter the length of fft'); %compute fft

disp('fourier transformed signal');

X=fft(x,n)

subplot(1,2,1);stem(x); title('i/p signal');

xlabel('n --->');

ylabel('x(n) -->');grid;

subplot(1,2,2);stem(X);

title('fft of i/p x(n) is:');

xlabel('Real axis --->');

ylabel('Imaginary axis -->');

grid;
COMMAND WINDOW:

enter the sequence:[1/2 1/2 1/2 1/2 0 0 0 0]

enter the length of fft:8

fourier transformed signal

X = Columns 1 through 6

2.0000 + 0.0000i 0.5000 - 1.2071i 0.0000 + 0.0000i 0.5000 - 0.2071i


0.0000 + 0.0000i 0.5000 + 0.2071i

Columns 7 through 8

0.0000 + 0.0000i 0.5000 + 1.2071i

OUTPUT WAVEFORMS:

i/p signal fft of i/p x(n) is:


0.5 1.5

0.45
1
0.4

0.35
0.5
Imaginary axis -->

0.3
x(n) -->

0.25 0

0.2
-0.5
0.15

0.1
-1
0.05

0 -1.5
0 2 4 6 8 0 2 4 6 8
n ---> Real axis --->

RESULT:Thus the MATLAB program to imlement N-Point FFT(Fast Fourier


Transform )was performed and the Output was verified.
EXPERIMENT-13

POWER DENSITY SPECTRUM OF A SEQUENCE


AIM:To compute the power density spectrum of a given sequence.

EQUIPMENTS:

Operating System-Windows 10

Software-MATLAB R2014a

THEORY:

The power spectral density(P.S.D) is a measurement of the energy at


various frequencies In the previous section we saw how to unwrap the FFT and
get back the sine and cosine coefficients. Usually we only care how much
information is contained at a particular frequency and we don’t really care
whether it is part of the sine or cosine series. Therefore, we are interested in
the absolute value of the FFT coefficients. The absolute value will provide you
with the total amount of information contained at a given frequency, the
square of the absolute value is considered the power of the signal. Remember
that the absolute value of the Fourier coefficients are the distance of the
complex number from the origin. To get the power in the signal at each
frequency (commonly called the power spectrum) you can try the following
commands.

>> N = 8; %% number of points

>> t = [0:N-1]’/N; %% define time

>> f = sin(2*pi*t); %%define function

>> p = abs(fft(f))/(N/2); %% absolute value of the fft

>> p = p(1:N/2).^2 %% take the positve frequency half, only

This set of commands will return something much easier to understand,


you should get 1 at a frequency of 1 and zeros everywhere else. Try
substituting cos for sin in the above commands, you should get the same
result. Now try making >>f = sin(2*pi*t) + cos(2*pi*t). This change should
result in twice the power contained at a frequency of 1.

PROCEDURE:

1. Start the MATLAB program.


2. Open new M-file.
3. Type the program.
4. Save in current directory.
5. Compile and run the program.
6. For the Output see command window\Figure window

PROGRAM:

%Power spectral density

t = 0:0.001:0.6;

x = sin(2*pi*50*t)+sin(2*pi*120*t);

y = x + 2*randn(size(t));

subplot(2,1,1);

% figure(1);

stem(1000*t(1:50),y(1:50))

title('Signal Corrupted with Zero-Mean Random Noise')

xlabel('time (milliseconds)');

Y = fft(y,512);

%The power spectral density, a measurement of the energy at various


frequencies, is:

Pyy = Y.* conj(Y) / 512;

f = 1000*(0:256)/512;

subplot(2,1,2);
% figure(2);

stem(f,Pyy(1:257))

title('Frequency content of y');

xlabel('frequency (Hz)');

OUTPUT WAVEFORMS:

RESULT:Thus the MATLAB program to compute the Power density spectrum


was performed and the output was verified.

You might also like