15LEB369
15LEB369
figure(2)
z1 = fft(x, len);
k=0:1:len-1;
subplot(2,1,1)
%val1=abs(z1);
stem(k, abs(z1))
title('Magnitude of the DFT samples')
xlabel('Fequency index k') Question 7
ylabel('Magnitude')
z2 = fft(y, len);
k=0:1: L+len-1 ; len =input('enter the length of sequence: ');
M= input('enter the down-sampling factor: ');
subplot(2,1,2) f= input('enter the signal frequency: ');
n=[0:1:len-1];
stem(abs(z2)) m=0 : len *M-1;
title('Magnitude of the upsampled DFT samples') x=sin(2*pi*f*m);
xlabel('Fequency index k') y = downsample(x,M);
ylabel('Magnitude') figure(1)
subplot(2,1,1)
stem(n,x(1: len));
title('Input Sequence');
xlabel('Time Index n');
OUTPUT: ylabel('Amplitude');
enter the length of sequence: 50 subplot(2,1,2)
enter the ussampling factor: 3 stem(y);
enter the signal frequency: 0.042 title(['Input Sequence down-sampled by: ',
num2str(M)]);
xlabel('Time Index n');
ylabel('Amplitude');
figure(2)
z1 = fft(x, len);
k=0:1:len-1;
subplot(2,1,1)
%val1=abs(z1);
stem(k, abs(z1))
title('Magnitude of the DFT samples')
xlabel('Fequency index k')
ylabel('Magnitude')
z2 = fft(y, len);
k=0:1: M+len-1 ; Question 9
subplot(2,1,2) f=150;
t=[0:0.001:10];
stem(abs(z2)) c=[];
title('Magnitude of the down-sampled DFT x = sin( 2 * pi * f .* t);
samples') snr = [20:-5:-20];
xlabel('Fequency index k') for i=1:9
ylabel('Magnitude') y= awgn(x, snr(i));
z= corrcoef(x,y);
c=[c, z(1,2)]
end
figure()
OUTPUT: plot(snr,c)
enter the length of sequence: 50 title('Correlation coefficient Vs SNR')
enter the down-sampling factor: 3 xlabel('signal to noise ratio')
enter the signal frequency: 0.042 ylabel('correlation coefficient')
Question 10
clc;
clear all;
close all;
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
fs = 5000; P1(2:end-1) = 2*P1(2:end-1);
ts = 1/fs; f = Fs*(0:(L/2))/L;
L = 1500; plot(f,P1)
t = (0:L-1)*ts; xlabel('Spectrum of Input Signal')
title('Spectrum of Signal')
x = cos(2*pi*500*t) + cos(2*pi*1000*t) subplot(3,1,2)
+cos(2*pi*1500*t); M = fft(y1);
Fctff1 = 800 P2 = abs(M/L);
P1 = P2(1:L/2+1);
d1 = designfilt('lowpassfir', 'FilterOrder', 20, P1(2:end-1) = 2*P1(2:end-1);
'CutoffFrequency', ... f = Fs*(0:(L/2))/L;
Fctff1, 'SampleRate', 5000, 'Window', 'hamming'); plot(f,P1)
xlabel(['Spectrum of Signal passed through Low
Fctff2 = 1100; Pass Filter,Cutoff frequency ' num2str(Fctff1) ''])
d2 = designfilt('highpassfir', 'FilterOrder', 20, subplot(3,1,3)
'CutoffFrequency', ... M = fft(y2);
Fctff2, 'SampleRate', 5000, 'Window', 'hamming'); P2 = abs(M/L);
P1 = P2(1:L/2+1);
h1=impz(d1); P1(2:end-1) = 2*P1(2:end-1);
y1 = conv(x,h1); f = Fs*(0:(L/2))/L;
h2=impz(d2); plot(f,P1)
y2 = conv(x,h2); xlabel(['Spectrum of Signal passed through High
Pass Filter,Cutoff frequency ' num2str(Fctff2) ''])
figure;
subplot(3,1,1);
t=0:1:length(x)-1;
stem(t,x);
axis([0 50 -4 4])
xlabel('Input Signal')
ylabel('Amplitude')
title('Signal in Time Domain')
subplot(3,1,2);
t=0:1:length(y1)-1;
stem(t,y1);
axis([0 50 -4 4])
xlabel('Output when passed through Low Pass
Filter')
ylabel('Amplitude')
subplot(3,1,3);
t=0:1:length(y2)-1;
stem(t,y2);
axis([0 50 -4 4])
xlabel('Output when passed through High Pass
Filter')
ylabel('Amplitude')
figure;
subplot(3,1,1)
Y = fft(x);
Question number 11
clc;
clear all;
close all;
[x fs] = audioread('enjoy_10K_corrupted.wav');
sound(x, fs);
wo = 0.3;
bw = wo/5;
figure;
subplot(3,1,1);
t=0:1:n
stem(t,x2);
axis([0 50 -1 1])
xlabel('Input 2')
ylabel('Amplitude')
Question 13 subplot(3,1,2);
t=0:1:length(y2_1)-1;
stem(t,y2_1);
clc; axis([0 50 -1 1])
clear all; xlabel('Output through system 1')
close all; ylabel('Amplitude')
subplot(3,1,3);
n=50 t=0:1:length(y2_2)-1;
b1 = [1/3 1/3 1/3]; stem(t,y2_2);
b2 = [1/3 -1/3 1/3]; axis([0 50 -1 1])
a = [1]; xlabel('Output through system 2')
ylabel('Amplitude')
fvtool(b1,a)
fvtool(b2,a)
h1 = impz(b1,a,n)
h2 = impz(b2,a,n)
t=0:1:n
x1 = sin(2*pi*(pi/4)*t);
x2 = sin(2*pi*(pi)*t);
y1_1= conv(x1,h1);
y1_2= conv(x1,h2);
y2_1= conv(x2,h1);
y2_2= conv(x2,h2);
subplot(3,1,1);
stem(t,x1);
axis([0 50 -1 1])
xlabel('Input 1')
ylabel('Amplitude')
subplot(3,1,2);
t=0:1:length(y1_1)-1;
stem(t,y1_1);
axis([0 50 -1 1])
xlabel('Output through system 1')
ylabel('Amplitude')
subplot(3,1,3);
0.1000
0.0900
Question14 0.2350
0.2341
clc; 0.0799
clear all; -0.0874
close all; -0.1448
-0.0796
b = [0 1 -1.2 1]; 0.0277
a = [1 -1.3 1.04 -0.222]; 0.0867
0.0661
h1 = impz(b,a,100) 0.0020
fvtool(b,a) -0.0469
fvtool(b,a,'polezero') -0.0484
ISstable_yes1_no0 = isstable(b,a) -0.0137
0.0221
fs = 2048; % Sampling frequency 0.0323
t = 1/fs; % Sampling period 0.0159
L = 50; % Length of signal -0.0080
n = (0:L-1)*t; -0.0197
-0.0138
s= sin(1800*n/fs) + sin(1900*n/fs) + 0.0008
sin(2000*n/fs); 0.0110
y=conv(s,h1); 0.0104
0.0023
figure; -0.0054
subplot(2,1,1) -0.0071
Y = fft(s); -0.0031
P1 = abs(Y/L); 0.0022
f = fs*(0:L-1)/L; 0.0045
plot(f,P1) 0.0029
xlabel('Spectrum of Input Signal') -0.0004
title('Spectrum of Signal') -0.0026
subplot(2,1,2) -0.0022
M = fft(y); -0.0003
P1 = abs(M/L); 0.0013
f = fs*(0:length(y)-1)/length(y); 0.0016
plot(f,P1) 0.0006
xlabel('Spectrum of Signal passed through Filter') -0.0006
-0.0010
-0.0006
0.0002
a) since poles are located other than origin 0.0006
hence iir filter. 0.0005
0.0000
From the response it is clear that given filter -0.0003
is notch filter. -0.0003
-0.0001
b) h1 = 0.0001
0.0002
0 0.0001
1.0000 -0.0000
-0.0001
-0.0001
0.0000
0.0001
0.0001
0.0000
-0.0000
-0.0000
-0.0000
0.0000
0.0000
0.0000
-0.0000
-0.0000
-0.0000
-0.0000
0.0000
0.0000
0.0000
-0.0000
-0.0000
-0.0000
0.0000
0.0000
0.0000
0.0000
-0.0000
-0.0000
-0.0000
0.0000
0.0000
0.0000
-0.0000
-0.0000
-0.0000
-0.0000
0.0000
0.0000
0.0000
-0.0000
-0.0000
-0.0000
0.0000
0.0000
0.0000
-0.0000
ISstable_yes1_no0 =