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

DSP Manual

The document describes experiments conducted in a digital signal processing lab to generate and analyze various signals and sequences using MATLAB. The experiments include: 1) Generating step, impulse, ramp, exponential and sawtooth sequences. 2) Generating the sum of sinusoidal signals. 3) Implementing and verifying linear and circular convolution. 4) Implementing and verifying auto and cross correlation. 5) Implementing and verifying the discrete Fourier transform (DFT) of a signal. 6) Implementing and verifying the fast Fourier transform (FFT) of a signal. 7) Designing analog low-pass and high-pass filters. 8) Designing IIR Butterworth

Uploaded by

yaswanth98801
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

DSP Manual

The document describes experiments conducted in a digital signal processing lab to generate and analyze various signals and sequences using MATLAB. The experiments include: 1) Generating step, impulse, ramp, exponential and sawtooth sequences. 2) Generating the sum of sinusoidal signals. 3) Implementing and verifying linear and circular convolution. 4) Implementing and verifying auto and cross correlation. 5) Implementing and verifying the discrete Fourier transform (DFT) of a signal. 6) Implementing and verifying the fast Fourier transform (FFT) of a signal. 7) Designing analog low-pass and high-pass filters. 8) Designing IIR Butterworth

Uploaded by

yaswanth98801
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

DIGITAL SIGNAL PROCESSING LAB

EXPERIMENT-1 : GENERATION OF VARIOUS SIGNALS AND SEQUENCES


AIM: TO GENERATE VARIOUS SIGNALS AND SEQUENCES USING MATLAB
SOFTWARE REQUIRED : PC INSTALLED WITH MATLAB SOFTWARE
PROCEDURE: 1.OPEN MATLAB SOFTWARE
2.OPEN NEW FILE
3.TYPE THE PROGRAM
4.RUN THE PROGRAM
5.CHECK OUTPUT IN COMMAND WINDOW AND OUTPUT GRAPHS
PROGRAM :
%STEP SEQUENCE
N=input('enter the length of sequence in even number');
x=ones(1,N);
n=0:1:N-1;
stem(n,x);
axis([-1 N -1 2]);
title('step sequence');
xlabel('samples');
ylabel('amplitude');
OUTPUT : ENTER THE LENGTH OF SEQUENCE IN EVEN NUMBER: 20

%IMPULSE SEQUENCE
clc;
clear all;
close all;
N=input('enter the length of sequence in even number');
N1=N/2;
x= [zeros(1,N1) ones(1,1) zeros(1,N1)];
n= -N1:1:N1;
stem(n,x);
axis([-N1 N1 -1 2]);
title('impulse sequence');
xlabel('samples');
ylabel('amplitude');
OUTPUT : ENTER THE LENGTH OF SEQUENCE IN EVEN NUMBER: 20

%RAMP SEQUENCE
clc;
clear all;
close all;
N=input('enter the length of sequence in even number');
n=0:1:N-1;
x=n;
stem(n,x);
axis([-1 N -1 N]);
title('Ramp sequence');
xlabel('samples');
ylabel('amplitude');
grid on
OUTPUT : ENTER THE LENGTH OF SEQUENCE IN EVEN NUMBER: 20

%EXPONENTIAL SEQUENCE
clc;
clear all;
close all;
N=input('enter the length of sequence in even number');
n=0:1:N-1;
x=exp(-n);
stem(n,x);
axis([-1 N -1 2]);
title('exponential sequence');
xlabel('samples');
ylabel('amplitude');
grid on
OUTPUT : ENTER THE LENGTH OF SEQUENCE IN EVEN NUMBER: 20

%SAWTOOTH SEQUENCE
clc;
clear all;
close all;
F=input('enter frequency');
f=6;
fs=10*f;
n=0:1/fs:1;
s=sawtooth(2*pi*4*n);
stem(n,s);
title('sawtooth sequence');
xlabel('time');
ylabel('amplitude');
OUTPUT : ENTER THE FREQUENCY: 20
EXPERIMENT-2 : GENERATION OF SUM OF SINUSOIDAL SIGNALS
AIM: TO GENERATE SUM OF SINUSOIDAL SIGNALS
SOFTWARE REQUIRED : PC INSTALLED WITH MATLAB SOFTWARE
PROCEDURE: 1.OPEN MATLAB SOFTWARE
2.OPEN NEW FILE
3.TYPE THE PROGRAM
4.RUN THE PROGRAM
5.CHECK OUTPUT IN COMMAND WINDOW AND OUTPUT GRAPHS
PROGRAM :
clc;
clear all;
close all;
n=-4:0.5:4;
y1=sin(n);
subplot(2,2,1);
stem(n,y1,'filled');
grid on;
xlabel('samples');
ylabel('magnitude');
title('sinusoidal signal');
y2=sin(2*n);
subplot(2,2,2);
stem(n,y2,'filled');
grid on;
xlabel('samples');
ylabel('magnitude');
title('sinusoidal signal');
y3=y1+y2;
subplot(2,1,2);
stem(n,y3,'filled');
xlabel('samples');
ylabel('magnitude');
title('sum of sinusoidal signal');
EXPERIMENT-3 : IMPLEMENTATION AND VERIFICATION OF LINEAR AND CIRCULAR CONVOLUTION
AIM: TO IMPLEMENT AND VERIFY OF LINEAR AND CIRCULAR CONVOLUTION
SOFTWARE REQUIRED : PC INSTALLED WITH MATLAB SOFTWARE
PROCEDURE: 1.OPEN MATLAB SOFTWARE
2.OPEN NEW FILE
3.TYPE THE PROGRAM
4.RUN THE PROGRAM
5.CHECK OUTPUT IN COMMAND WINDOW AND OUTPUT GRAPHS
A)LINEAR CONVOLUTION PROGRAM :
clc;
clear all;
close all;
disp('enter the length of first sequence m=');
m=input(' ');
disp('enter the length of first sequence x(m)=');
for i=1:m;
x(i)=input(' ');
end
disp('enter the length of second sequence n=');
n=input(' ');
disp('enter the length of second sequence h(n)= ');
for j=1:n;
h(j)=input(' ');
end
y=conv(x,h);
figure;
subplot(3,1,1);
stem(x);
ylabel('amplitude');
xlabel('n');
title('x(n) vs n');
subplot(3,1,2);
stem(h);
ylabel('amplitude');
xlabel('n');
title('h(n)vs n');
subplot(3,1,3);
stem(y);
ylabel('amplitude');
xlabel('n');
title('y(n) vs n');
disp('linear convolution of x(n) and h(n) is y');
OUTPUT: enter the length of first sequence m=4
enter the length of first sequence x(m)= 1
2
3
4
enter the length of second sequence n=
5
enter the length of second sequence h(n)=

1
2
3
4
5
linear convolution of x(n) and h(n) is y

B)CIRCULAR CONVOLUTION PROGRAM :


clc;
clear all;
close all;
x=input('enter the input sequence x(n)=');
h=input('enter the impulse response sequence h(n)=');
n1=length(x);
n2=length(h);
y=cconv(x,h,max(n1,n2));
n=length(y);
disp('input sequence x(n):');
disp(x);
disp('input response h(n):');
disp(h);
disp('output of discrete LTI system is');
disp(y);
disp('press enter for graphs');
pause
b=0:1:n1-1;
a=stem(b,x);
title('input');
xlabel('time');
ylabel('amplitude');
pause
b=0:1:n2-1;
a=stem(b,h);
title('impulse');
xlabel('time');
ylabel('amplitude');
pause
b=0:1:n-1;
a=stem(b,y);
title('output');
xlabel('time');
ylabel('amplitude');

OUTPUT:
enter the input sequence x(n)=
[1 2 3 4]
enter the impulse response sequence h(n)=
[1 2 3 4 5]
input sequence x(n):
1 2 3 4

input response h(n):


1 2 3 4 5

output of discrete LTI system is


35 35 30 20 30

press enter for graphs


EXPERIMENT-4 : IMPLEMENT AND VERIFY AUTO AND CROSS CORRELATION
AIM: TO IMPLEMENT AND VERIFY AUTO AND CROSS CORRELATION
SOFTWARE REQUIRED : PC INSTALLED WITH MATLAB SOFTWARE
PROCEDURE: 1.OPEN MATLAB SOFTWARE
2.OPEN NEW FILE
3.TYPE THE PROGRAM
4.RUN THE PROGRAM
5.CHECK OUTPUT IN COMMAND WINDOW AND OUTPUT GRAPHS
PROGRAM :
clc;
clear all;
close all;
%two input sequences
x=input('enter the sequence');
h=input('enter the impulse sequence');
subplot(2,2,1);
stem(x);
xlabel('n');
ylabel('x(n)');
title('input sequence');
subplot(2,2,2);
stem(h);
xlabel('n');
ylabel('h(n)');
title('impulse sequence');
%auto correlation
z=xcorr(x,x);
subplot(2,2,3);
stem(z);
disp(z);
xlabel('n');
ylabel('z(n)');
title('auto correlation');
%CROSS CORRELATION
y=xcorr(x,h);
subplot(2,2,4);
stem(y);
disp(y);
xlabel('n');
ylabel('y(n)');
title('cross correlation');
OUTPUT:

enter the sequence


[1 2 3 4 5]
enter the impulse sequence
[1 2 3 4 5 6]
AUTO-5.0000 14.0000 26.0000 40.0000 55.0000 40.0000 26.0000 14.0000
5.0000

CROSS-6.0000 17.0000 32.0000 50.0000 70.0000 55.0000 40.0000 26.0000


14.0000 5.0000 0.0000

EXPERIMENT-5 : IMPLEMENT AND VERIFY DFT OF A SIGNAL


AIM: TO IMPLEMENT AND VERIFY DFT OF A SIGNAL
SOFTWARE REQUIRED : PC INSTALLED WITH MATLAB SOFTWARE
PROCEDURE: 1.OPEN MATLAB SOFTWARE
2.OPEN NEW FILE
3.TYPE THE PROGRAM
4.RUN THE PROGRAM
5.CHECK OUTPUT IN COMMAND WINDOW AND OUTPUT GRAPHS
PROGRAM :
clc;
clear all;
close all;
a = input('enter the sequence = ');
N = length(a);
disp('The length of the sequence');
y = zeros(1, N); % Initialize y before using it
for k = 1:N
y(k)=0
for i = 1:N
y(k) = y(k) + a(i) * exp([-2*pi*j/N]*[(i-1)*(k-1)]);N
end
end
k = 1:N;
disp('the result is:');y
figure(1);
subplot(2,1,1);
stem(k, abs(y(k)));
grid;
xlabel('sample values n----->');
ylabel('Amplitude------->');
title('magnitude response of the DFT of the given sequence');
subplot(2,1,2);
stem(angle(y) * 180 / pi);
xlabel('sample values n');
ylabel('phase');
title('phase response of the DFT of the given sequence');
OUTPUT:

enter the sequence =


[1 2 3 4]
N=4
y = 10.0000 + 0.0000i -2.0000 + 2.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i

EXPERIMENT-6 : IMPLEMENT AND VERIFY FFT OF A SIGNAL


AIM: TO IMPLEMENT AND VERIFY FFT OF A SIGNAL
SOFTWARE REQUIRED : PC INSTALLED WITH MATLAB SOFTWARE
PROCEDURE: 1.OPEN MATLAB SOFTWARE
2.OPEN NEW FILE
3.TYPE THE PROGRAM
4.RUN THE PROGRAM
5.CHECK OUTPUT IN COMMAND WINDOW AND OUTPUT GRAPHS
PROGRAM :
clc;
clear all;
close all;
N=8;
m=8;
a=input('enter the input sequence');
n=0:1:N-1;
subplot(2,2,1);
stem(n,a);
xlabel('Time signal n');
ylabel('amplitude');
title('input signal');
d=fft(a,m);
disp(d);
k=0:1:N-1;
subplot(2,2,2);
stem(k,abs(d));
xlabel('frequency index k');
ylabel('magnitude');
title('magnitude response');
subplot(2,2,3);
stem(k,angle(d));
xlabel('frequency index k');
ylabel('phase');
title('phase response');
OUTPUT: enter the input sequence

[1 1 0 0 1 1 0 0]
FFT- 4.0000 + 0.0000i 0.0000 + 0.0000i 2.0000 - 2.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i 2.0000 + 2.0000i 0.0000 + 0.0000i

EXPERIMENT-7 : DESIGN OF ANALOG FILTERS


AIM: TO DESIGN ANALOG FILTERS
SOFTWARE REQUIRED : PC INSTALLED WITH MATLAB SOFTWARE
PROCEDURE: 1.OPEN MATLAB SOFTWARE
2.OPEN NEW FILE
3.TYPE THE PROGRAM
4.RUN THE PROGRAM
5.CHECK OUTPUT IN COMMAND WINDOW AND OUTPUT GRAPHS
PROGRAM : A)LPF
clear all;
close all;
f=100:20:8000;
fb=900;
k=length(f);
for i=1:k;
m(i)=1/sqrt(1+(f(i)/fb)^2);
mag(i)=20*log10(m(i));
end
figure;
semilogx(f,mag);
title('magnitude response of analog of LPF');
xlabel('frequency');
ylabel('magnitude in db');
grid on;
OUTPUT:

B)HPF
clear all;
close all;
f=100:20:8000;
fl=400;
k=length(f);
for i=1:k;
m(i)=1/sqrt(1+(fl/f(i))^2);
mag(i)=20*log10(m(i));
end
figure;
semilogx(f,mag);
title('magnitude response of analog of HPF');
xlabel('frequency');
ylabel('magnitude in db');
grid on;
EXPERIMENT-8 : DESIGN OF IIR BUTTERWORTH FILTER AND VERIFY FREQUENCY RESPONSE
AIM: TO DESIGN IIR FILTER
SOFTWARE REQUIRED : PC INSTALLED WITH MATLAB SOFTWARE
PROCEDURE: 1.OPEN MATLAB SOFTWARE
2.OPEN NEW FILE
3.TYPE THE PROGRAM
4.RUN THE PROGRAM
5.CHECK OUTPUT IN COMMAND WINDOW AND OUTPUT GRAPHS
PROGRAM :
A)LPF
clc;
clear all;
close all;
format long;
rp=input('enter pass band ripple');
rs=input('enter the stopband ripple');
wp=input('enter the passband frequency');
ws=input('enter the stopband frequency');
fs=input('enter the sampling frequency');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s');
[z,p,k]=butter(n,wn);
[b,a]=butter(n,wn,'s');
w=0:0.01:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
plot(om/pi,m);
title('magnitude plot of lpf iir');
ylabel('gain in db');
xlabel('(a)normalised freq');
subplot(2,1,2);
plot(om/pi,an);
title('phase response of lpf iir filter');
ylabel('phase in db');
xlabel('(b)normalised freq');
OUTPUT:

enter pass band ripple 0.6


enter the stopband ripple 60
enter the passband frequency 1500
enter the stopband frequency 3000
enter the sampling frequency 7000
B)HPF
clc;
clear all;
close all;
format long;
rp=input('enter pass band ripple');
rs=input('enter the stopband ripple');
wp=input('enter the passband frequency');
ws=input('enter the stopband frequency');
fs=input('enter the sampling frequency');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s');
[z,p,k]=butter(n,wn);
[b,a]=butter(n,wn,'high','s');
w=0:0.01:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
plot(om/pi,m);
title('magnitude plot of hpf iir');
ylabel('gain in db');
xlabel('(a)normalised freq');
subplot(2,1,2);
plot(om/pi,an);
title('phase response of hpf iir filter');
ylabel('phase in db');
xlabel('(b)normalised freq');
OUTPUT:
enter pass band ripple 0.2
enter the stopband ripple 40
enter the passband frequency 2000
enter the stopband frequency 3500
enter the sampling frequency 8000
EXPERIMENT-9 : DESIGN OF FIR FILTER USING WINDOWING TECHNIQUE
AIM: TO DESIGN FIR FILTER USING WINDOWING TECHNIQUE
SOFTWARE REQUIRED : PC INSTALLED WITH MATLAB SOFTWARE
PROCEDURE: 1.OPEN MATLAB SOFTWARE
2.OPEN NEW FILE
3.TYPE THE PROGRAM
4.RUN THE PROGRAM
5.CHECK OUTPUT IN COMMAND WINDOW AND OUTPUT GRAPHS
PROGRAM :

A)USING RECTANGULAR WINDOW


clc;
clear all;
close all;
rp=input('Enter the passband ripple(rp):');
rs=input('Enter the stopband ripple(rs):');
fp=input('Enter the passband frequency(fp):');
fs=input('Enter the stopband frequency(fs):');
f=input('Enter the sampling frequency(f):');
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);
%Low pass filter
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,1,1);
plot(m);
ylabel('Gain(db)->');
xlabel('(a)Normalised frequency->');
%High pass filter
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,1,2);
plot(m);
ylabel('Gain(db)->');
xlabel('(b)Normalised frequency->');
OUTPUT:
Enter the passband ripple(rp):
0.01
Enter the stopband ripple(rs):
0.04
Enter the passband frequency(fp):
1000
Enter the stopband frequency(fs):
2000
Enter the sampling frequency(f):
5000

B)USING KAISER WINDOW


clc;
clear all;
format long;
rp=input('Enter the passband ripple(rp):');
rs=input('Enter the stopband ripple(rs):');
fp=input('Enter the passband frequency(fp):');
fs=input('Enter the stopband frequency(fs):');
f=input('Enter the sampling frequency(f):');
beta=input('Enter the beta value:');
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=kaiser(n1,beta);
%Low pass filter
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,1,1);
plot(o/pi,m);
ylabel('Gain(db)->');
xlabel('(a)Normalised frequency->');
title('KAISER WINDOW')
%High pass filter
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,1,2);
plot(o/pi,m);
ylabel('Gain(db)->');
xlabel('(b)Normalised frequency->');

OUTPUT:
Enter the passband ripple(rp):
0.01
Enter the stopband ripple(rs):
0.04
Enter the passband frequency(fp):
1000
Enter the stopband frequency(fs):
2000
Enter the sampling frequency(f):
5000
Enter the beta value:
2

EXPERIMENT-10: COMPUTE THE DECIMATION AND INTERPOLATION OF GIVEN SIGNAL

AIM: TO COMPUTE THE DECIMATION AND INTERPOLATION OF GIVEN SIGNAL


SOFTWARE REQUIRED : PC INSTALLED WITH MATLAB SOFTWARE
PROCEDURE: 1.OPEN MATLAB SOFTWARE
2.OPEN NEW FILE
3.TYPE THE PROGRAM
4.RUN THE PROGRAM
5.CHECK OUTPUT IN COMMAND WINDOW AND OUTPUT GRAPHS
PROGRAM :

a)decimation
clc;
clear all;
close all;
M = input ('enter Down-sampling factor: ');
N = input ('enter number of samples :');
n = 0: N-1;
x = sin (2*pi*0.043*n) + sin (2*pi*0.031*n);
y = decimate(x, M,'fir');
subplot(2, 1, 1);
stem (n,x(1:N));
title ('Input Sequence');
xlabel ('Time index n');
ylabel ('Amplitude');
subplot(2, 1, 2);
m = 0:(N/M)
stem (m,y);
title('Output Sequence');
xlabel('Time index n');
ylabel('Amplitude');
output:
enter Down-sampling factor: 3
enter number of samples :100

b)interpolation
clc;
clear all;
close all;
L=input('enter the upsampling factor');
N=input('enter the length of the input signal'); % Length should be greater than 8
f1=input('enter the frequency of first sinusoidal');
f2=input('enter the frequency of second sinusoidal');
n=0:N-1;
x=sin(2*pi*f1*n)+sin(2*pi*f2*n);
y=interp(x,L);
subplot(2,1,1)
stem(n,x(1:N))
title('input sequence');
xlabel('time(n)');
ylabel('amplitude');
subplot(2,1,2)
m=0:N*L-1;
stem(m,y(1:N*L))
title('output sequence ');
xlabel('time(n)');
ylabel('amplitude');
output:
enter the upsampling factor
4
enter the length of the input signal
12
enter the frequency of first sinusoidal
5
enter the frequency of second sinusoidal
10

EXPERIMENT-11: DESIGN OF IIR CHEBYSHEV FILTER AND VERIFY FREQUENCY RESPONSE


AIM: TO DESIGN IIR CHEBYSHEV FILTER
SOFTWARE REQUIRED : PC INSTALLED WITH MATLAB SOFTWARE
PROCEDURE: 1.OPEN MATLAB SOFTWARE
2.OPEN NEW FILE
3.TYPE THE PROGRAM
4.RUN THE PROGRAM
5.CHECK OUTPUT IN COMMAND WINDOW AND OUTPUT GRAPHS
PROGRAM :
A)CHEBYSHEV TYPE 1 LOW PASS ANALOG FILTER
clc;
close all;
clear all;
format long
rp=input('enter the passband ripple...');
rs=input('enter the stopband ripple...');
wp=input('enter the passband freq...');
ws=input('enter the stopband freq...');
fs=input('enter the sampling freq...');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=cheb1ord(w1,w2,rp,rs,'s');
[b,a]=cheby1(n,rp,wn,'s');
W=0:.01:pi;
[h,om]=freqs(b,a,W);
M=20*log10(abs(h));
An=angle(h);
subplot(2,1,1);
plot(om/pi,M);
ylabel('Gain in dB --.');
xlabel('(a) Normalised frequency --.');
title('magnitude response')
subplot(2,1,2);
plot(om/pi,An);
xlabel('(b) Normalised frequency --.');
ylabel('Phase in radians --.');
title('phase response')
output:
enter the passband ripple...0.34
enter the stopband ripple...34
enter the passband freq...1400
enter the stopband freq...1600
enter the sampling freq...10000

B)CHEBYSHEV TYPE 2 HIGH PASS ANALOG FILTER


clc;
close all;
clear all;
format long
rp=input('enter the passband ripple...');
rs=input('enter the stopband ripple...');
wp=input('enter the passband freq...');
ws=input('enter the stopband freq...');
fs=input('enter the sampling freq...');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=cheb2ord(w1,w2,rp,rs,'s');
[b,a]=cheby2(n,rs,wn,'high','s');
w=0:.01:pi;
[h,om]=freqs(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
plot(om/pi,m);
ylabel('Gain in dB --.');
xlabel('(a) Normalised frequency --.');
title('magnitude response');
subplot(2,1,2);
plot(om/pi,an);
xlabel('(b) Normalised frequency --.');
ylabel('Phase in radians --.');
title('phase response');
output:
enter the passband ripple...0.34
enter the stopband ripple...34
enter the passband freq...1400
enter the stopband freq...1600
enter the sampling freq...10000

EXPERIMENT-12: Real time implementation of an audio signal using a digital signal


processor.
AIM: To Real time implementation of an audio signal using a digital signal processor.
SOFTWARE REQUIRED : PC INSTALLED WITH MATLAB SOFTWARE
PROCEDURE: 1.OPEN MATLAB SOFTWARE
2.OPEN NEW FILE
3.TYPE THE PROGRAM
4.RUN THE PROGRAM
5.CHECK OUTPUT IN COMMAND WINDOW AND OUTPUT GRAPHS
PROGRAM :

a)LPF
clc;
close all;
clear all;
% LPF
[dataIn,Fs]=audioread('mary_trumpet_adsr-38724.mp3');
% Filter the signal
fc=500; % make higher to hear higherfrequnecies
% design a Butterworth filter
[b,a]=butter(6,fc/Fs);
subplot(2,1,1);
stem(a);
xlabel('normalised frequency');
ylabel('magnitude in db');
title('magnitude response of audio signal');
subplot(2,1,2);
stem(b);
xlabel('normalised frequency');
ylabel('phase in db');
title('phase response of audio signal');
% Apply the BUtterworth filter
filtered_signal=filter(b,a,dataIn);
% Play the sound
player=audioplayer(filtered_signal,Fs);
play(player);

b)hpf
clc;
close all;
clear all;
% HPF
[dataIn,Fs]=audioread('mary_trumpet_adsr-38724.mp3');
% Filter the signal
fc=500; % make higher to hear higherfrequnecies
% design a Butterworth filter
[b,a]=butter(6,fc/(Fs/2));
subplot(2,1,1);
stem(a);
xlabel('normalised frequency');
ylabel('magnitude in db');
title('magnitude response of audio signal');
subplot(2,1,2);
stem(b);
xlabel('normalised frequency');
ylabel('phase in db');
title('phase response of audio signal');
% Apply the BUtterworth filter
filtered_signal=filter(b,a,dataIn);
% Play the sound
player=audioplayer(filtered_signal,Fs);
play(player);

EXPERIMENT-13: Compute the correlation coefficient for the two given audio signals of same
length using a digital signal processor.
AIM: To Compute the correlation coefficient for the two given audio signals of same length using a
digital signal processor.

SOFTWARE REQUIRED : PC INSTALLED WITH MATLAB SOFTWARE


PROCEDURE: 1.OPEN MATLAB SOFTWARE
2.OPEN NEW FILE
3.TYPE THE PROGRAM
4.RUN THE PROGRAM
5.CHECK OUTPUT IN COMMAND WINDOW AND OUTPUT GRAPHS
PROGRAM :
clc;
close all;
[x,~]=audioread("mary_trumpet_adsr-38724.mp3");
[y,fs]=audioread("Machine-Gun-Automatic-Fire-A-www.fesliyanstudios.com.mp3");
x1=length(x);
y1=length(y);
d=corrcoef(x1,y1);
disp('corrcoef is');d
fc=100;
[b,a]=butter(6,fc/fs);
subplot(2,1,1);
stem(a);
xlabel('normalised frequency');
ylabel('magnitude in db');
title('magnitude response of audio signal');
subplot(2,1,2);
stem(b);
xlabel('normalised frequency');
ylabel('phase in db');
title('phase response of audio signal');
output:
correlation coefficient is d =1

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy