Professional Documents
Culture Documents
figure(1);
subplot(4,1,1);
stem(x_seq,'g');
title ('Input x(n) sequence');
xlabel ('"n" samples no.');
ylabel ('Amplitude');
subplot(4,1,2);
stem(h_seq,'r');
title ('Input h(n) sequence');
xlabel ('"n" samples no.');
ylabel ('Amplitude');
subplot(4,1,3);
stem(y_seq,'g');
title ('Output (convolved) x(n)*h(n) sequence');
xlabel ('"n" samples no.');
ylabel ('Amplitude');
len_1 = length(x_seq);
len_2 = length(h_seq);
N = len_1+len_2-1;
% N = abs(len_1-len_2);
x_new = x_seq;
h_new = h_seq;
zer_1 = zeros(1,N-len_1);
zer_2 = zeros(1,N-len_2);
h_new = [h_seq zer_2];
x_new = [x_seq zer_1];
h_new2 = fliplr(h_new);
h_new3 = h_new2;
h_new4 = h_new3;
for j = 1:N
for i=1:N
tmp = h_new3(N);
if i<N
h_new4(i+1) = h_new3(i);
end
if i == N
h_new4(1) = tmp;
end
end
h_new3 = h_new4;
y_new(j) = x_new*h_new3';
end
disp('Linear convolution using circular convolution ouput signal');
disp(y_new);
M_N = max(len_1,len_2);
dum = 0;
while (M_N>0)
M_N = M_N-2;
dum = dum+1;
end
N2 = 2^dum;
x_new = x_seq;
h_new = h_seq;
zer_11 = zeros(1,N2-len_1);
zer_21 = zeros(1,N2-len_2);
h_new21 = fliplr(h_new1);
h_new31 = h_new21;
h_new41 = h_new31;
for j = 1:N2
for i=1:N2
tmp = h_new31(N2);
if i<N2
h_new41(i+1) = h_new31(i);
subplot(3,2,3);
stem(h_c);
title ('second sequence of Cross correlation');
subplot(3,2,4);
stem(y_cxx);
title ('Auto correlation of x(n)');
xlabel ('Samples "n"');
ylabel ('Amplitude');