Professional Documents
Culture Documents
DSP Record
DSP Record
Aim:
To Study the following Mat lab Function of Standard Commands and Write the
simple program of signal.
Apparatus Required:
Hardware: PC.
Software: MATLAB 2011a Version.
Algorithm:
1. Start the program.
2. Get the value of length of the sequence N.
3. Give the steps to generate Unit Step, Unit Impulse, Unit Ramp, Sine Signal, Cosine
Signal and Exponential Signal.
4. Output is generated in discrete format.
5. Terminate the Process.
Program:
clc;
clear all;
close all;
N=input('Enter the length of the sequence:');
Input:
Output:
x5=exp(t);
subplot(2,3,6);
stem(t,x5);
xlabel('Exponential');
ylabel('Amplitude');
Title('Generation of Exponential sequence');
Continuous Assessment
Max Allotted
S.No Components
mark Marks
3. Record 10
4. Viva Voce 10
Total 100
Result:
Thus the MATLAB program for generation of basic signals is executed and waveforms are
plotted successfully.
Aim:
To write a MATLAB Program to obtain discrete Fourier transform for the
system given in any form of the sequence using FFT algorithm and verify manual and
practical value.
Apparatus Required:
Hardware: PC.
Algorithm:
1. Start the program.
2. Get the finite duration sequence x(n).
3. Calculate the value of N.
4. DFT is calculated using DIT and DIF algorithm.
a. Calculate the magnitude response.
b. Plot the magnitude response.
5. Verify manual and built in function values.
6. Terminate the process.
Program:
% DIT Algorithm
clc;
clear all
close all
xn=input('enter the sequence: ');
N=input('enter the length: ');
p=length(xn);
if N>p
xn=[xn,zeros(1,N-p)];
else
xn=xn;
end
lev=log2(N);
Input:
Output:
x=bitrevorder(xn);
tw=exp(-i*2*pi*(0:N/2-1)/N);
for levn=1:lev;
L=2^levn;
twl=tw(1:N/L:N/2);
for k=0:L:N-L;
for n=0:L/2-1;
A=x(n+k+1);
B=x(n+k+(L/2)+1)*twl(n+1);
x(n+k+1)=A+B;
x(n+k+(L/2)+1)=A-B;
end
end
end
x
l=0:N-1;
subplot(3,2,1),stem(l,xn);
title('input');
xlabel('n');
ylabel('x[n]');
subplot(3,2,2),stem(l,abs(x));
title('FFT using DIT algorithm');
xlabel('k');
ylabel('X[k]');
subplot(3,2,3),stem(l,abs(fft(xn)));
title('FFT using function');
xlabel('k');
ylabel('X[k]');
ansft=fft(xn)
%ifft
N=length(x);
xn1=conj(x);
lev=log2(N);
x1=bitrevorder(xn1);
tw=exp(-2i*pi*(0:N/2-1)/N);
for levn=1:lev;
L=2^levn;
twl=tw(1:N/L:N/2);
Input:
Output:
for k=0:L:N-L
for n=0:L/2-1
A=x1(n+k+1);
B=x1(n+k+(L/2)+1)*twl(n+1);
x1(n+k+1)=A+B;
x1(n+k+(L/2)+1)=A-B;
end
end
end
X=conj(x1)/N
subplot(3,2,4);stem(l,abs(X));
title('IFFT using DIT algorithm');
xlabel('n');
ylabel('x[n]');
subplot(3,2,5);stem(l,abs(ifft(x)));
title('IFFT using function’);
xlabel('n');
ylabel('x[n]');
ansift=ifft(x)
% DIF ALGORITHM
clc;
clear all;
close all;
xn=input('enter a sequence:');
p=length(xn);
N=input('Enter the value of N ');
if N>p
xn=[xn,zeros(1,N-p)];
else
xn=xn;
end
x=xn;
lev=log2(N);
tw=exp(-2i*pi*(0:N/2-1)/N);
for level=lev:-1:1;
L=2^level;
twlvl=tw(1:N/L:N/2);
for k=0:L:N-L;
Input:
Output:
for n=0:L/2-1;
A=x(n+k+1);
B=x(n+k+(L/2)+1);
x(n+k+1)=A+B;
x(n+k+(L/2)+1)=(A-B)*twlvl(n+1);
end
end
end
XK=bitrevorder(x);
l=0:N-1;
subplot(3,2,1),stem(l,abs(xn));
title('input’);
xlabel('n');
ylabel('x[n]');
subplot(3,2,2),stem(l,abs(XK));
title('FFT using DIF algorithm');
xlabel('k');ylabel('X[k]');
ansft=fft(xn)
subplot(3,2,3),stem(l,abs(fft(xn)));
title('FFT using function');
xlabel('k');ylabel('X[k]');
%ifft
x1=conj(XK);
levels=log2(N);
tw=exp(-2i*pi*(0:N/2-1)/N);
for level=levels:-1:1;
L=2^level;
twlvl=tw(1:N/L:N/2);
for k=0:L:N-L;
for n=0:L/2-1;
A=x1(n+k+1);
B=x1(n+k+(L/2)+1);
x1(n+k+1)=A+B;
x1(n+k+(L/2)+1)=(A-B)*twlvl(n+1);
end
end
end
x=bitrevorder(x1);
Input:
Output:
xk=conj(x)/N
ansift=ifft(XK)
subplot(3,2,4),stem(l,abs(xk));
title('IFFT using DIF algorithm-');
xlabel('n');
ylabel('x[n]');
subplot(3,2,5),stem(l,abs(ansift));
title('IFFT using function');
xlabel('n');ylabel('x[n]');
Continuous Assessment
Max Allotted
S.No Components
mark Marks
3. Record 10
4. Viva Voce 10
Total 100
Result:
Thus the MATLAB Programs for FFT using DIF and DIT Algorithm for the given finite
duration were generated using program and inbuilt function and is plotted successfully.
Aim:
Electronics and Communication Engineering Department
Digital Signal Processing Lab
To write a MATLAB Program to obtain the linear and circular convolution between
two finite duration sequence h(n) and x(n) and calculate FFT sequence.
Apparatus Required:
Hardware: PC.
Algorithm:
1. Start the program.
2. Get the input sequence.
3. Get the impulse sequence.
4. Write coding to find out the linear convolution and circular convolution.
5. Plot the convolution sequence.
6. Terminate the process.
Program:
clc;
clear all;
close all;
x=input('enter the input sequence');
h=input('enter the impulse sequence');
m=length(x);
n=length(h);
X=[x, zeros(1,n-1)];
H=[h, zeros(1,m-1)];
for i=1:n+m-1
y(i)=0;
for j=1:m
if(i-j+1>0)
y(i)=y(i)+X(j)*H(i-j+1);
Input:
Output:
else
end
end
end
y
Y=conv(x,h)
subplot(2,2,1);
stem(x);
xlabel('n samples--->');
ylabel('amplitude--->');
title('input signal');
subplot(2,2,2);
stem(h);
xlabel('n samples--->');
ylabel('amplitude--->');
title('impulse signal');
subplot(2,2,3);
stem(y);
xlabel('n samples-->');
ylabel('amplitude-->');
title('Linear Convolution using program');
stem(Y);
xlabel('n samples-->');
ylabel('amplitude-->');
title('Linear Convolution using function’);
Circular Convolution
clc;
clear all;
close all;
x=input('Enter the input sequences x(n):');
m=length(x);
h=input('Enter the impulse response h(n)');
n=length(h);
subplot(2,2,1);
stem(x);
title('Input sequencce x(n)');
xlabel('n ---->');
ylabel('x(n) ---->');
grid; subplot(2,2,2);
stem(h);
title('Impulse response h(n)');
xlabel('n ---->');
ylabel('h(n) ---->');
if(m-n~=0)
if(m>n)
h=[h,zeros(1,m-n)];
Input:
Output:
n=m;
end
if(n>m)
x=[x,zeros(1,n-m)];
disp('circular convolution of x(n) & h(n) is y(n):');
if(m-n~=0)
if(m>n)
h=[h,zeros(1,m-n)];
n=m;
end
if(n>m)
x=[x,zeros(1,n-m)];
m=n;
end
end
a=zeros(m,m)
a(:,1)=x
for i=1:n-1
a(:,i+1)=[a(n,i);a(1:n-1,i);
end
h1(:,1)=h;
y1=a*h1;
y(1,:)=y1;
y
subplot(2,2,3),stem(y);
title('convolution of x(n) & h(n)');
xlabel('n ---->');
ylabel('y(n) ---->');
Y=circonv(x,h,m)
subplot(2,2,3),stem(y);
title('convolution of x(n) & h(n) using inbuilt function');
xlabel('n ---->');
ylabel('y(n) ---->');
Continuous Assessment
Max Allotted
S.No Components
mark Marks
3. Record 10
4. Viva Voce 10
Total 100
Result:
Thus the MATLAB Program for linear and Circular convolution through program and inbuilt
function was generated and plotted successfully.
Aim:
To write a MATLAB Program to generate and plot the window technique.
1. Rectangular
2. Hanning
3. Hamming
4. Blackman
Apparatus Required:
Hardware: PC.
Algorithm:
1. Start the program.
2. Get the pass band and stop band ripples.
3. Get the stop and pass band frequency.
4. Get the sampling frequency.
5. Calculate the order of the filter (N=-20log10 (sqrt (rp*rs)) 13), dem=14.6*(fs-fp)/f.
6. Find the windows co-efficient using particular windows formula.
7. Draw the magnitude and phase response.
8. Terminate the program.
Program:
clc;
clear all;
close all;
rp=input('Enter the Pass Band Ripple:');
rs=input('Enter the Stop Band Ripple :');
fp=input('Enter the Pass Band Frequency :');
fs=input('Enter the Stop Band Frequency :');
f=input('Enter the Sampling Frequency :');
Input:
Output:
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
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);
Disp ('rectangular window filter response');
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);[h,o]=freqz(b,1,256);
plot(o/pi,m);
Title('LPF');
ylabel('Gain in dB');
xlabel('(a) Normalized Frequency');
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
b=fir1(n,wn,'stop',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,4);
plot(o/pi,m);
Title('BSF');
ylabel('Gain in dB');
xlabel('(d) Normalized Frequency');
Input:
Output:
clc;
clear all;
close all;
Input:
Output:
clc;
clear all;
close all;
rp=input('Enter the Pass Band Ripple:');
rs=input('Enter the Stop Band Ripple :');
fp=input('Enter the Pass Band Frequency :');
fs=input('Enter the Stop Band Frequency :');
f=input('Enter the Sampling Frequency :');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
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=hanning(n1);
Disp ('hanning window filter response');
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);[h,o]=freqz(b,1,256);
plot(o/pi,m);
Title('LPF');
ylabel('Gain in dB');
xlabel('(a) Normalized Frequency');
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
b=fir1(n,wn,'stop',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,4);
plot(o/pi,m);
Title('BSF');
ylabel('Gain in dB');
xlabel('(d) Normalized Frequency');
Input:
Output:
clear all;
close all;
rp=input('Enter the Pass Band Ripple:');
rs=input('Enter the Stop Band Ripple :');
fp=input('Enter the Pass Band Frequency :');
fs=input('Enter the Stop Band Frequency :');
f=input('Enter the Sampling Frequency :');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
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=blackman(n1);
Disp('Blackman Window Filter Response');
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);[h,o]=freqz(b,1,256);
plot(o/pi,m);
Title('LPF');
ylabel('Gain in dB');
xlabel('(a) Normalized Frequency');
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
b=fir1(n,wn,'stop',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,4);
plot(o/pi,m);
Title('BSF');
ylabel('Gain in dB');
xlabel('(d) Normalized Frequency');
Continuous Assessment
Max Allotted
S.No Components
mark Marks
3. Record 10
4. Viva Voce 10
Total 100
Result:
Thus the MATLAB Program for windows function rectangular, hamming, hanning and
blackmann were generated and plotted successfully
Aim:
To write a MATLAB Program to generate and plot the magnitude and phase
Response of IIR filter Digital filter.
Apparatus Required:
Hardware: PC.
Algorithm:
1. Start the program.
2. Use the given specification value and find the required coefficients.
3. Plot the magnitude and phase response.
4. Terminate the program.
Program:
1.Write a mat lab program to design a Butterworth Digital IIR Low Pass filter using bilinear
transformation by taking T=0.1 seconds, to satisfy the following Specifications.
0.6≤|H(ejω)| ≤1.0;for 0≤ω≤0.35π
clc;
clear all;
close all;
AP=0.6;
AS=0.1;
PEF=0.35*pi;
SEF=0.7*pi;
T=0.1;
alphap=-20*log10(AP)
alphas=-20*log10(AS)
PEFA=(2/T)*tan((PEF/2))
SEFA=(2/T)*tan((SEF/2))
[N,CF]=buttord(PEFA,SEFA,alphap,alphas,'s')
[Bn,An]=butter(N,1,'s');
display('Normalised Transfer Function is,')
Hsn=tf(Bn,An)
[B,A]=butter(N,CF,'s');
display('Un Normalised Transfer Function is,')
Hs=tf(B,A)
[num,den]=bilinear(B,A,1/T);
display('Digital Transfer Function is,')
Hz=tf(num,den,T)
w=0:pi/16:pi;
display('Frequency Response is,')
Hw=freqz(num,den,w)
display('Magnitude Response is,')
Hw_mag=abs(Hw)
plot(w/pi,Hw_mag,'k');
grid;
title('Magnitude Response of Second order Low pass Filter');
xlabel('Normalised Frequency');
ylabel('Magnitude');
Input:
Output:
2.Write a mat lab program to design a Butterworth Digital IIR High Pass filter using bilinear
transformation by taking T=0.1 seconds, to satisfy the following Specifications.
0.6≤|H(ejω)| ≤1.0;for 0.7π ≤ω≤π
|H(ejω)| ≤0.1;for 0≤ω≤0.35π
clc;
clear all;
close all;
AP=0.6;
AS=0.1;
PEF=0.35*pi;
SEF=0.7*pi;
T=0.1;
alphap=-20*log10(AP)
alphas=-20*log10(AS)
PEFA=(2/T)*tan((PEF/2))
SEFA=(2/T)*tan((SEF/2))
[N,CF]=buttord(PEFA,SEFA,alphap,alphas,'s')
[Bn,An]=butter(N,1,'s');
display('Normalised Transfer Function is,')
Hsn=tf(Bn,An)
[B,A]=butter(N,CF,'high','s');
display('Un Normalised Transfer Function is,')
Hs=tf(B,A)
[num,den]=bilinear(B,A,1/T);
display('Digital Transfer Function is,')
Hz=tf(num,den,T)
w=0:pi/16:pi;
display('Frequency Response is,')
Hw=freqz(num,den,w)
display('Magnitude Response is,')
Hw_mag=abs(Hw)
plot(w/pi,Hw_mag,'k');
grid;
title('Magnitude Response of Second order Low pass Filter');
xlabel('Normalised Frequency');
ylabel('Magnitude');
Input:
Output:
3.Write a mat lab program to design a Butterworth Digital IIR Low Pass filter using bilinear
transformation by taking T=0.5 seconds, to satisfy the following Specifications.
0.707≤|H(ejω)| ≤1.0;for 0≤ω≤0.45π
|H(ejω)| ≤0.2;for 0.65π≤ω≤π
clc;
clear all;
close all;
AP=0.707;
AS=0.2;
PEF=0.45*pi;
SEF=0.65*pi;
T=0.5;
alphap=-20*log10(AP)
alphas=-20*log10(AS)
PEFA=(2/T)*tan((PEF/2))
SEFA=(2/T)*tan((SEF/2))
[N,CF]=buttord(PEFA,SEFA,alphap,alphas,'s')
[Bn,An]=butter(N,1,'s');
display('Normalised Transfer Function is,')
Hsn=tf(Bn,An)
[B,A]=butter(N,CF,'s');
display('Un Normalised Transfer Function is,')
Hs=tf(B,A)
[num,den]=bilinear(B,A,1/T);
display('Digital Transfer Function is,')
Hz=tf(num,den,T)
w=0:pi/16:pi;
display('Frequency Response is,')
Hw=freqz(num,den,w)
display('Magnitude Response is,')
Hw_mag=abs(Hw)
plot(w/pi,Hw_mag,'k');
grid;
title('Magnitude Response of Third order Low pass Filter');
xlabel('Normalised Frequency');
ylabel('Magnitude');
Input:
Output:
4.Write a mat lab program to design a Butterworth Digital IIR High Pass filter using bilinear
transformation by taking T=0.5 seconds, to satisfy the following Specifications.
0.707≤|H(ejω)| ≤1.0;for 0.65π ≤ω≤π
|H(ejω)| ≤0.2;for 0≤ω≤0.45π
clc;
clear all;
Electronics and Communication Engineering Department
Digital Signal Processing Lab
close all;
AP=0.707;
AS=0.2;
PEF=0.45*pi;
SEF=0.65*pi;
T=0.5;
alphap=-20*log10(AP)
alphas=-20*log10(AS)
PEFA=(2/T)*tan((PEF/2))
SEFA=(2/T)*tan((SEF/2))
[N,CF]=buttord(PEFA,SEFA,alphap,alphas,'s')
[Bn,An]=butter(N,1,'s');
display('Normalised Transfer Function is,')
Hsn=tf(Bn,An)
[B,A]=butter(N,CF,'high','s');
display('Un Normalised Transfer Function is,')
Hs=tf(B,A)
[num,den]=bilinear(B,A,1/T);
display('Digital Transfer Function is,')
Hz=tf(num,den,T)
w=0:pi/16:pi;
display('Frequency Response is,')
Hw=freqz(num,den,w)
display('Magnitude Response is,')
Hw_mag=abs(Hw)
plot(w/pi,Hw_mag,'k');
grid;
title('Magnitude Response of Third order High pass Filter');
xlabel('Normalised Frequency');
ylabel('Magnitude');
Input:
Output:
5.Write a mat lab program to design a Butterworth Digital IIR Low Pass filter using impulse
invariance transformation by taking T=1 seconds, to satisfy the following Specifications.
0.707≤|H(ejω)| ≤1.0;for 0≤ω≤0.3π
|H(ejω)| ≤0.2;for 0.75π≤ω≤π
clc;
clear all;
close all;
AP=0.707;
AS=0.2;
Electronics and Communication Engineering Department
Digital Signal Processing Lab
PEF=0.3*pi;
SEF=0.75*pi;
T=1;
alphap=-20*log10(AP)
alphas=-20*log10(AS)
PEFA=PEF/T
SEFA=SEF/T
[N,CF]=buttord(PEFA,SEFA,alphap,alphas,'s')
[Bn,An]=butter(N,1,'s');
display('Normalised Transfer Function is,')
Hsn=tf(Bn,An)
[B,A]=butter(N,CF,'s');
display('Un Normalised Transfer Function is,')
Hs=tf(B,A)
[num,den]=impinvar(B,A,1/T);
display('Digital Transfer Function is,')
Hz=tf(num,den,T)
w=0:pi/16:pi;
display('Frequency Response is,')
Hw=freqz(num,den,w)
display('Magnitude Response is,')
Hw_mag=abs(Hw)
plot(w/pi,Hw_mag,'k');
grid;
title('Magnitude Response of Second order Low pass Filter');
xlabel('Normalised Frequency');
ylabel('Magnitude');
Input:
Output:
6.Write a mat lab program to design a Butterworth Digital IIR Low Pass filter using impulse
invariance transformation by taking T=1 seconds, to satisfy the following Specifications.
0.9≤|H(ejω)| ≤1.0;for 0≤ω≤0.35π
|H(ejω)| ≤0.275;for 0.7π≤ω≤π
clc;
clear all;
close all;
AP=0.9;
AS=0.275;
PEF=0.35*pi;
SEF=0.7*pi;
Electronics and Communication Engineering Department
Digital Signal Processing Lab
T=1;
alphap=-20*log10(AP)
alphas=-20*log10(AS)
PEFA=PEF/T
SEFA=SEF/T
[N,CF]=buttord(PEFA,SEFA,alphap,alphas,'s')
[Bn,An]=butter(N,1,'s');
display('Normalised Transfer Function is,')
Hsn=tf(Bn,An)
[B,A]=butter(N,CF,'s');
display('Un Normalised Transfer Function is,')
Hs=tf(B,A)
[num,den]=impinvar(B,A,1/T);
display('Digital Transfer Function is,')
Hz=tf(num,den,T)
w=0:pi/16:pi;
display('Frequency Response is,')
Hw=freqz(num,den,w)
display('Magnitude Response is,')
Hw_mag=abs(Hw)
plot(w/pi,Hw_mag,'k');
grid;
title('Magnitude Response of Third order Low pass Filter');
xlabel('Normalised Frequency');
ylabel('Magnitude');
Input:
Output:
7.Write a mat lab program to design a Butterworth Digital IIR Low Pass filter using impulse
invariance transformation by taking T=1 seconds, to satisfy the following Specifications.
0.8≤|H(ejω)| ≤1.0;for 0≤ω≤0.2π
|H(ejω)| ≤0.2;for 0.32π≤ω≤π
clc;
clear all;
close all;
AP=0.8;
AS=0.2;
PEF=0.2*pi;
SEF=0.32*pi;
T=1;
alphap=-20*log10(AP)
alphas=-20*log10(AS)
Electronics and Communication Engineering Department
Digital Signal Processing Lab
PEFA=PEF/T
SEFA=SEF/T
[N,CF]=buttord(PEFA,SEFA,alphap,alphas,'s')
[Bn,An]=butter(N,1,'s');
display('Normalised Transfer Function is,')
Hsn=tf(Bn,An)
[B,A]=butter(N,CF,'s');
display('Un Normalised Transfer Function is,')
Hs=tf(B,A)
[num,den]=impinvar(B,A,1/T);
display('Digital Transfer Function is,')
Hz=tf(num,den,T)
w=0:pi/16:pi;
display('Frequency Response is,')
Hw=freqz(num,den,w)
display('Magnitude Response is,')
Hw_mag=abs(Hw)
plot(w/pi,Hw_mag,'k');
grid;
title('Magnitude Response of Fourth order Low pass Filter');
xlabel('Normalised Frequency');
ylabel('Magnitude');
Input:
Output:
8.Write a mat lab program to design a Butterworth Digital IIR Low Pass filter using Bilinear
transformation by taking T=1 seconds, to satisfy the following Specifications.
0.707≤|H(ejω)| ≤1.0;for 0≤ω≤0.2π
|H(ejω)| ≤0.08;for 0.4π≤ω≤π
clc;
clear all;
close all;
AP=0.707;
AS=0.08;
PEF=0.2*pi;
SEF=0.4*pi;
T=1;
alphap=-20*log10(AP)
alphas=-20*log10(AS)
PEFA=PEF/T
SEFA=SEF/T
[N,CF]=buttord(PEFA,SEFA,alphap,alphas,'s')
Electronics and Communication Engineering Department
Digital Signal Processing Lab
[Bn,An]=butter(N,1,'s');
display('Normalised Transfer Function is,')
Hsn=tf(Bn,An)
[B,A]=butter(N,CF,'s');
display('Un Normalised Transfer Function is,')
Hs=tf(B,A)
[num,den]=bilinear(B,A,1/T);
display('Digital Transfer Function is,')
Hz=tf(num,den,T)
w=0:pi/16:pi;
display('Frequency Response is,')
Hw=freqz(num,den,w)
display('Magnitude Response is,')
Hw_mag=abs(Hw)
plot(w/pi,Hw_mag,'k');
grid;
title('Magnitude Response of Fourth order Low pass Filter');
xlabel('Normalised Frequency');
ylabel('Magnitude');
Input:
Output:
9.Write a mat lab program to design a Chebyshev Digital IIR Low Pass filter using impulse
invariance transformation by taking T=1 seconds, to satisfy the following Specifications.
0.9≤|H(ejω)| ≤1.0;for 0≤ω≤0.25π
|H(ejω)| ≤0.24;for 0.5π≤ω≤π
clc;
clear all;
close all;
AP=0.9;
AS=0.24;
PEF=0.25*pi;
SEF=0.5*pi;
T=1;
alphap=-20*log10(AP)
alphas=-20*log10(AS)
PEFA=PEF/T
SEFA=SEF/T
[N,CF]=cheb1ord(PEFA,SEFA,alphap,alphas,'s')
[Bn,An]=cheby1(N,alphap,1,'s');
display('Normalised Transfer Function is,')
Electronics and Communication Engineering Department
Digital Signal Processing Lab
Hsn=tf(Bn,An)
[B,A]=cheby1(N,alphap,CF,'s');
display('Un Normalised Transfer Function is,')
Hs=tf(B,A)
[num,den]=impinvar(B,A,1/T);
display('Digital Transfer Function is,')
Hz=tf(num,den,T)
w=0:pi/16:pi;
display('Frequency Response is,')
Hw=freqz(num,den,w)
display('Magnitude Response is,')
Hw_mag=abs(Hw)
plot(w/pi,Hw_mag,'k');
grid;
title('Magnitude Response of Third order Low pass Filter');
xlabel('Normalised Frequency');
ylabel('Magnitude');
Input:
Output:
10.Write a mat lab program to design a Chebyshev Digital IIR Low Pass filter using Bilinear
transformation by taking T=1 seconds, to satisfy the following Specifications.
0.8≤|H(ejω)| ≤1.0;for 0≤ω≤0.2π
|H(ejω)| ≤0.2;for 0.32π≤ω≤π
clc;
clear all;
close all;
AP=0.8;
AS=0.2;
PEF=0.2*pi;
SEF=0.32*pi;
T=1;
alphap=-20*log10(AP)
alphas=-20*log10(AS)
PEFA=(2/T)*tan(PEF/2)
SEFA=(2/T)*tan(SEF/2)
[N,CF]=cheb1ord(PEFA,SEFA,alphap,alphas,'s')
[Bn,An]=cheby1(N,alphap,1,'s');
display('Normalised Transfer Function is,')
Hsn=tf(Bn,An)
[B,A]=cheby1(N,alphap,CF,'s');
display('Un Normalised Transfer Function is,')
Electronics and Communication Engineering Department
Digital Signal Processing Lab
Hs=tf(B,A)
[num,den]=bilinear(B,A,1/T);
display('Digital Transfer Function is,')
Hz=tf(num,den,T)
w=0:pi/16:pi;
display('Frequency Response is,')
Hw=freqz(num,den,w)
display('Magnitude Response is,')
Hw_mag=abs(Hw)
plot(w/pi,Hw_mag,'k');
grid;
title('Magnitude Response of Third order Low pass Filter');
xlabel('Normalised Frequency');
ylabel('Magnitude');
Input:
Output:
Continuous Assessment
Max Allotted
S.No Components
mark Marks
3. Record 10
Electronics and Communication Engineering Department
4. Viva Voce 10
Total 100
Digital Signal Processing Lab
Result:
Thus the MATLAB Program for design of IIR Filter was generated and plotted successfully.
Aim:
To write a MATLAB Program to generate spectrum of various FFT length.
Apparatus Required:
Hardware: PC.
Software: 7.0.4.version.
Algorithm:
1. Start the program.
2. Get input signal for which power spectrum is to be drawn.
3. Plot the power spectrum for different N values.
4. Terminate the program.
Program:
clc;
clear all;
close all;
x=input('enter the input sequence');
l=length(x);
N=8;
psd=abs(fft(x,N)).^2/(l);
stem((0:N-1)/N,psd);
xlim([0 1]);
xlabel(‘Discrete Frequency f, f=k/N, k=0,1....N-
1’,’fontsize’,12,’fontweight’,’b’);
ylabel (‘power’,’fontsize’,12,’fontweight’,’b’);
title(‘Power spectrum, FFT length N=8’,’fontsize’,12,’fontweight’,’b’);
N=16;
psd=abs(fft(x,N)).^2/(l);figure;
stem((0:N-1)/N,psd);
xlim([0 1]);
xlabel(‘Discrete Frequency f, f=k/N, k=0,1....N-1’);
ylabel (‘power’,’fontsize’,12,’fontweight’,’b’);
title(‘Power spectrum, FFT length N=16’);
N=32;
psd=abs(fft(x,N)).^2/(l); figure;
stem((0:N-1)/N,psd);
xlim([0 1]);
xlabel(‘Discrete Frequency f, f=k/N, k=0,1....N-
1’,’fontsize’,12,’fontweight’,’b’);
ylabel (‘power’,’fontsize’,12,’fontweight’,’b’);
title(‘Power spectrum, FFT length N=32’);
N=64;
psd=abs(fft(x,N)).^2/(l); figure;
stem((0:N-1)/N,psd);
xlim([0 1]);
xlabel(‘Discrete Frequency’);
ylabel (‘power’);
title(‘Power spectrum, FFT length N=64’);
Continuous Assessment
Max Allotted
S.No Components
mark Marks
3. Record 10
Electronics and Communication Engineering Department
4. Viva Voce 10
Total 100
Digital Signal Processing Lab
Result:
Thus the MATLAB Program for power spectrum is plotted successfully.
2. Select C67xx simulator board and add then save & quit.
3. Start a new project using Project New pull down menu, save it in a separate directory (D:\
My projects) with file name project name.pjt.
4. Create a new source file using FileNewSource file menu and save it in the project folder
(project name.c).
5. Add the source file (project name.c) to the project ProjectAdd files to ProjectSelect
project name.c
6. Add the linker command file hello.cmd ProjectAdd files to Project(path: C:\CCstudio\
tutorial\dsk6713\hello\hello.cmd)
7. Add the run time support library file rts6700.libProjectAdd files to Project(path: C\
CCStudio\cgtools\lib\rts6700.lib)
10. Load the project name.out file (from project folder project name\Debug) using FileLoad
Program
Aim:
To Write a DSP Processor Program to Generate a following standard signal.
1. Sinusoidal wave.
2. Cosine wave.
3. Square wave
Apparatus Required:
Hardware: PC.
Software: CCS 6713, 6713 Debugger
Theory:
The SPLK instruction allows a full 16-bit pattern to be written in to any memory location.
The parallel logic unit supports this bit manipulation independently of the ALU so that the ACC is un
affected.
ALGORITHM:
Step 1: Start the program.
Step 2: Define a float variable a.
OUTPUT:
Program:
Sinusoidal signal
#include<stdio.h>
#include<math.h>
float a[100];
main ( )
{ int i;
for(i=0;i<99;i++)
{a[i]=sin(2*3.14*5*i/100);
printf(“%f,a[i]);
}}
Cosine signal
#include<stdio.h>
#include<math.h>
float a[100];
main ( )
{ int i;
for(i=0;i<99;i++)
{
a[i]=cos(2*3.14*5*i/100);
printf(“%f”,a[i]);
}
}
OUTPUT:
Continuous Assessment
Max Allotted
S.No Components
mark Marks
3. Record 10
4. Viva Voce 10
Total 100
Result:
Thus the C program for generation of different wave form is executed and plotted through
processor successfully.
AIM:
To write a C program to obtain the linear convolution between two finite duration sequences
x(n) and h(n).
ALGORITHM:
Step 1: Start the program.
Step 2: Get the sequence x(n).
Step 3: Get the range of the sequence x(n).
Step 4: Get the sequence h(n).
Step 5: Get the range of the sequence h(n)..
Step 6: Find the convolution between the sequences x(n) and h(n)
Step 7: Plot the convoluted sequence y(n).
Step 8: Terminate the process.
PROGRAM:
Linear convolution:
#include<stdio.h>
#include<math.h>
int y[20];
void main()
{
int m=4;
int n=4;
int i=0;j;
int x[15]={1,2,3,4};
int h[15]={1,2,2,1};
int y(20);
Input:
Output:
for(i=0;i<m+n-1;i++)
}
y[i=0];
for(j=0;j<=i;j++)
y[i]=x[j]*h[i-j];
for(i=0;m+n-1;i++)
printf(“%d\n”,y[i]);
}
Circular convolution:
#include<stdio.h>
int m,n,x[30],h[30],y[30],i,j,temp[30],k,x2[30],a[30];
void main()
{
printf("Enter the length of 1st sequence\n");
scanf("%d",&m);
printf("Enter the length of 2nd sequence\n");
scanf("%d",&n);
printf("Enter the 1st sequence\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf("Enter the 2nd sequence\n");
for(j=0;j<n;j++)
scanf("%d",&h[j]);if(m-n!=0){if(m>n)
{
for(i=n;i<m;i++)
h(i)=0;
n=m;
}
for(i=m;i<n;i++)
x[i]=0;
m=n;
}
y[0]=0;
a[0]=h[0];
for(j=1;j<n;j++)
a[j]=h[n-j];
Input:
Output:
for(i=0;i<n;i++)
y[0]+=x[i]*a[i];
for(k=1;k<n;k++)
{
y[k]=0;
for(j=1;j<n;j++)
x2[j]=a[j-1];
x2[0]=a[n-1];
for(i=0;i<n;i++)
{
a[i]=x2[i];
y[k]+=x[i]*x2[i];
}
}
printf("The circular convolution is \n");
for(i=0;i<n;i++)
printf("%d\t",y[i]);
}
Continuous Assessment
Max Allotted
S.No Components
mark Marks
3. Record 10
4. Viva Voce 10
Total 100
Result:
Thus the C program for calculation of linear convolution and circular convolution was
successfully completed.
AIM:
To write a C program to obtain FIR filter design.
ALGORITHM:
Step 1: Start the program.
Step 2: Define pi value
Step 3: Get the number of samples.
Step 4: Get the choice of windows.
Step 5: Calculate the output.
Step 6: Terminate the process.
PROGRAM:
#include<stdio.h>
#include<math.h>
#define pi 3.1415
int n,N,c;
float wr[64],wt[64];
void main()
scanf("%d",&N);
scanf("%d",&c);
switch(c)
Output:
case 1:
for(n=0;n<=N-1;n++)
wr[n]=1;
printf(" \n wr[%d]=%f",n,wr[n]);
break;
case 2:
for(n=0;n<=N-1;n++)
wt[n]=1-(2*(float)n/(N-1));
printf("\n wt[%d]=%f",n,wt[n]);
break;
}
Continuous Assessment
Max Allotted
S.No Components
mark Marks
3. Record 10
4. Viva Voce 10
Total 100
Result:
Thus the C program for Loaded and design of FIR was successfully calculated and plotted.
AIM:
To write a C program to obtain IIR filter design.
ALGORITHM:
Step 1: Start the program.
Step 2: Get the value for order, cut of frequency, and choice of filter.
Step 3: Calculate the output.
Step 4: Terminate the process.
PROGRAM:
#include<stdio.h>
#include<math.h>
nt i,w,wc,c,N;
float H[100];
void main()
scanf("%d",&N);
scanf("%d",&wc);
printf("\n enter the choice for IIR filter 1. LPF 2.HPF ");
scanf("%d",&c);
switch(c)
Output:
case 1:
for(w=0;w<100;w++)
H[w]=1/sqrt(1+mul((w/(float)wc),2*N));
printf("H[%d]=%f\n",w,H[w]);
break;
case 2:
for(w=0;w<=100;w++){H[w]=1/sqrt(1+mul((float)wc/w,2*N));
printf("H[%d]=%f\n",w,H[w]);
break;
for(i=0;i<x-1;i++)
a*=a;
return(a);
}.
Continuous Assessment
Max Allotted
S.No Components
mark Marks
3. Record 10
4. Viva Voce 10
Total 100
Result:
Thus the C program is Loaded for design of IIR filter was successfully completed and plotted.