DSP Assignment 3
DSP Assignment 3
1. Pre-Lab
1.4 Sampling and Aliasing DEMO
1.4.a Set the input to x(t)=cos(40πt).
1.4.b Set the sampling rate to fs=24 samples/sec.
1.4.c ω=2π*20/24=5.24.
1.4.d The output frequency is 4Hz.
2.1.e Change the sampling frequency to 12 Hz. The output signal is flat line.
3. FIR Filters
3.1.a
3.1.b
3.1.1.Restoration Filter
3.1.2.b The plot shows consistency almost all throughout except from a range of about 23-33. I
would assume that the quality of restoration, as per the graph is a very good one.
Ghosting is caused by convolution calculations in matlab. The resulting image is of course not
the same as the original image. This is because at a specific point it was delayed. The last value
of the process was not equal, so it produced the value for the input.
3.2.3 M=11 M=22 M=33 M=44 M=55 M=66
% % 2.5.a
% data=load('echart.mat');
% bb = 1/5*ones(1,5);
% a=data.echart;
% show_img(a);
% b=firfilt(bb,a);
% % 2.5.b
% bdiffh=[1, -1];
% yy1=conv2(a,bdiffh);
% show_img(yy1);
% yy2=conv2(a,bdiffh');
% show_img(yy2);
% nn = 1:length(a);
% subplot(2,1,1);
% stem(nn,data.x1(nn))
% xlim([35 65])
% subplot(2,1,2);
% stem(nn,b(nn),'filled') %--Make black dots
% xlim([35 65])
% xlabel('Time Index (n)')
% w[n]=x[n]-0.9x[n-1];
% % 3.1
% xx = 256*(rem(0:100,50)<10);
% bb = [1,-0.9];
% nn = [0:75];
% subplot(2,1,1);
% stem(nn,xx(nn+1));
% xlabel('Time Index [n]')
% ylabel('xx Output')
% subplot(2,1,2);
% ww = firfilt(bb,xx);
% stem(nn,ww(nn+1),'Filled');
% xlabel('Time Index [n]');
% ylabel('ww Output');
% % 3.1.1
% xx = 256*(rem(0:100,50)<10);
% bb = [1,-0.9];
% nn = (0:75);
% subplot(2,1,1);
% ww = firfilt(bb,xx);
% stem(nn,ww(nn+1),'filled')
% xlabel('Time Index[n]')
% ylabel('ww Output')
% M = 22;
% r = 0.9;
% l = 0:M;
% yy = firfilt((r.^l),ww);
% subplot(2,1,2);
% stem(nn,yy(nn+1),'Filled');
% xlabel('Time Index[n]')
% ylabel('yy Output')
% % 3.1.2
% xx = 256*(rem(0:100,50)<10);
% bb = [1,-0.9];
% nn = (0:49);
% subplot(3,1,1);
% stem(nn,xx(nn+1))
% xlabel('Time Index(n)')
% ylabel('xx Input')
% ww = firfilt(bb,xx);
% M = 22;
% r = 0.9;
% l = 0:M;
% yy = firfilt((r.^l),ww);
% subplot(3,1,2);
% stem(nn,yy(nn+1),'Filled');
% xlabel('Time Index[n]')
% ylabel('yy Output')
% zz(nn+1)= xx(nn+1)-yy(nn+1);
% subplot(3,1,3);
% plot(nn,zz(nn+1));
% title('Worst case error b/w xx and yy ');
% max(abs(zz(nn+1)))
% bb = [1,zeros(1,1599),0.9];
% length(bb)
% load labdat
% xx = x2;
% bb = [1,zeros(1,1599),0.9];
% nn = [0: length(xx)];
% yy = firfilt(bb,xx);
% subplot(2,1,1);
% stem(xx);
% ylabel('Speech')
% subplot(2,1,2);
% stem(nn,yy(nn+1));
% xlabel('Time Index[n]');
% ylabel('Speech Echo');
% sound(yy(nn+1));
% % 3.2.1.a
% bb1 = [1,-0.9];
% imp = 1;
% M = 22;
% r = 0.9;
% l = 0:M;
% bb2 = r.^l;
% HH = firfilt(bb1,bb2);
% XX = firfilt(HH,imp);
% nn = 0:(length(HH)-1);
% stem(nn,XX(nn+1));
% xlabel('Time Index [n]')
% ylabel('Impulse Response')
% 3.2.2
data=load('echart.mat');
bb = [1,-0.9];
yy = conv2(data.echart,bb);
ech90 = conv2(yy,bb');
% show_img(ech90);
M = 11;
r = 0.9;
l = 0:M;
bb2 = r.^l;
zz = conv2(ech90,bb2);
ech90_filter2 = conv2(zz,bb2');
show_img(ech90_filter2);