'256 Points of XH and Sampled X' 'N' 'X (N) ' On Off
'256 Points of XH and Sampled X' 'N' 'X (N) ' On Off
1.
2.
3.
4.
5.
6.
7.
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
.....................................................................................................................................
1.
ts=1/8182;
n=0:8192;
xh=cos(2*pi*200*n*ts);
m=8;
x=xh(1:m:8192);
plot(n(1:256),xh(1:256));
title('256 points of xh and sampled x')
xlabel('n')
ylabel('x[n]')
hold on;
stem(n(1:m:256),x(1:256/8));
hold off;
soundsc(x);
1
2
3
4
5
6
7
2.
x0=zeros(1,8192);
x0(1:m:8192)=x;
plot(n(1:256),xh(1:256));
title('256 points of xh and sampled x0')
xlabel('n')
ylabel('x0[n]')
hold on;
stem(n(1:256),x0(1:256));
hold off;
soundsc(x0);
3.
f1=[0,1,1,1,1,1,1,1,1,0];
x1=conv(x0,f1);
plot(n(1:256),xh(1:256));
title('256 points of xh and sampled x1')
xlabel('n')
ylabel('x1[n]')
hold on;
stem(n(1:256),x1(1:256));
hold off;
soundsc(x1);
4.
f2=[0,1/8,2/8,3/8,4/8,5/8,6/8,7/8,1,7/8,6/8,5/8,4/8,3/8,2/8,1/8,0];
x2=conv(x0,f2);
plot(n(1:256),xh(1:256));
%stem(n(1:256),xh(1:256),'filled');
title('256 points of xh and sampled x2')
xlabel('n')
ylabel('x2[n]')
hold on;
stem(n(1:256),x2(1:256));
hold off
soundsc(x2);
% In this reconstruction, 59th sample of x2 is eq. to 51nd sample of xh
5.
f3 = sin(pi*1024*[-16:16]/8192+eps)./(pi*1024*[-16:16]/8192+eps);
f3w = f3.*hann(33)';
x3=conv(x0,f3w);
plot(n(1:256),xh(1:256));
xlabel('n')
ylabel('x3[n]')
%stem(n(1:256),xh(1:256),'filled');
title('256 points of xh and sampled x3')
hold on;
stem(n(1:256),x3(1:256));
hold off;
soundsc(x3);
% In this reconstruction, 108th sample of x3 is eq. to 92nd sample of xh
6.
f4 = sin(pi*1024*[-32:32]/8192+eps)./(pi*1024*[-32:32]/8192+eps);
f4w = f4.*hann(65)';
x4=conv(x0,f4w);
plot(n(1:256),xh(1:256));
xlabel('n')
ylabel('x4[n]')
%stem(n(1:256),xh(1:256),'filled');
title('256 points of xh and sampled x4')
hold on;
stem(n(1:256),x4(1:256));
hold off;
soundsc(x4);
% In this reconstruction, 83rd sample of x4 is eq. to 92nd sample of xh
7.
%
%
%
%
st1 and st2 are the starting indices of xi and xh which are needed to
account for the delay between xi and xh
In this part errors for various reconstructions are plotted after
appropriately shifting them
st1=59;
st2=51;
e2=abs(x2(st1:256+st1-1)-xh(st2:256+st2-1));
plot(n(1:256),e2(1:256));
xlabel('n')
ylabel('abs(x2[n]-xh[n])')
title('error for reconstruction x2')
st1=108;
st2=92;
e3=abs(x3(st1:256+st1-1)-xh(st2:256+st2-1));
plot(n(1:256),e3(1:256));
xlabel('n')
ylabel('abs(x3[n]-xh[n])')
title('error for reconstruction x3')
st1=83;
st2=92;
e4=abs(x4(st1:256+st1-1)-xh(st2:256+st2-1));
plot(n(1:256),e4(1:256));
xlabel('n')
ylabel('abs(x2[n]-xh[n])')
title('error for reconstruction x4')
10