Matrix Dimensions Must Agree Error for Cross Correlation
clear;
clc;
close all;
%x
n = 1:200;
phi = 0;
x_n = (cos(pi*n/15) + phi);
%e
N = 200;
e_n = 30*(rand(N,1)-0.5);
%x+e
x_ne = x_n + e_n;
%h depending upon which K value is used
n1 = 0:10;
h_n1 = cos(pi*n1/15);
n2 = 0:20;
h_n2 = cos(pi*n2/15);
n3 = 0:40;
h_n3 = cos(pi*n3/15);
n4 = 0:80;
h_n4 = cos(pi*n4/15);
%correlation length
corr1 = length(x_ne)+length(h_n1)-1;
corr2 = length(x_ne)+length(h_n2)-1;
corr3 = length(x_ne)+length(h_n3)-1;
corr4 = length(x_ne)+length(h_n4)-1;
%cross correlation
y1 = fftshift(ifft(fft(x_ne,n).*conj(fft(h_n1,corr1))))
y2 = fftshift(ifft(fft(x_ne,n).*conj(fft(h_n2,corr2))));
y3 = fftshift(ifft(fft(x_ne,n).*conj(fft(h_n3,corr3))));
y4 = fftshift(ifft(fft(x_ne,n).*conj(fft(h_n4,corr4))));
%plotting each y
subplot(4,1,1)
stem(n1, y1)
subplot(4,1,2)
stem(n2, y2)
subplot(4,1,3)
stem(n3, y3)
subplot(4,1,4)
stem(n4, y4)
0 Commenti
Risposte (1)
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!