Professional Documents
Culture Documents
DSP Lab
DSP Lab
n = 0:N-1;
x=random(1,N);
figure;
Subplot(2,1,1);
Plot(n,x);
Xlabel(‘ ‘);
Ylabel(‘X’);
subplot(2,1,2);
stem(n,x);
xlabel(‘n’);
ylabel(‘X’);
3) % Auto correlation
Clc;
Clear all;
Close all;
n=length(x);
z=flip(x);
m=length(z);
l1=0:n-1;
figure;
subplot(2,1,1);
stem(l1,x);
xlabel(‘----> n’);
ylabel(‘---->x(n)’);
grid;
x=[x,zeros(l,m)];
z=[z,zeros(l,n)];
y=zeros(l,m+n-1);
for i=1:m+n-1
y(i)=0;
for j=1:m+n-1
if(j<i+1)
y(i)=y(i)+z(j)*x(i-j);
end
end
end
disp(y);
l2= -(n-1):(n-1);
subplot(2,1,2);
stem(l2,y);
xlabel(‘--->n’);
ylabel(‘--->y(n)’);
grid;