Laode Marzujriban
Laode Marzujriban

Reputation: 13

Cross Correlating each pair column of matrices in matlab

I have a problem when I want to do cross correlating two matrices in matlab. The code looks like this:

load a.dat
load b.dat
x1 = a(:,m)
x2 = b(:,m)
m = 1:3;
for m=1:3;
x = xcrorr(x1,x2);
end

Both a and b are (1500 x 3) matrices, I want to cross correlate each column and get the value in 3 columns, i.e. as same as the data.

Upvotes: 1

Views: 135

Answers (1)

yoh.lej
yoh.lej

Reputation: 1104

load a.dat
load b.dat
for m=1:3
  x1 = a(:,m);
  x2 = b(:,m);
  x(:,m) = xcorr(x1,x2);
end

which you could shorten to:

load a.dat
load b.dat
for m=1:3
  x(:,m) = xcorr(a(:,m),b(:,m));
end

Upvotes: 3

Related Questions