You are on page 1of 2

1) %generation of random signal

N=input(‘enter the value of n:’);

n = 0:N-1;

x=random(1,N);

figure;

Subplot(2,1,1);

Plot(n,x);

Xlabel(‘ ‘);

Ylabel(‘X’);

title(‘continuous random signal’);

subplot(2,1,2);

stem(n,x);

xlabel(‘n’);

ylabel(‘X’);

title(‘discrete random signal’);

3) % Auto correlation

Clc;

Clear all;

Close all;

x=input(‘enter the sequence x(n):’);

n=length(x);

z=flip(x);

m=length(z);

l1=0:n-1;

figure;

subplot(2,1,1);

stem(l1,x);

title(‘input sequence x(n) is :’);

xlabel(‘----> n’);
ylabel(‘---->x(n)’);

grid;

x=[x,zeros(l,m)];

z=[z,zeros(l,n)];

disp(‘auto correlation of x(n) & X(n) is Y(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);

title(‘auto correlation of x(n) & X(n) is :’);

xlabel(‘--->n’);

ylabel(‘--->y(n)’);

grid;

You might also like