Reputation: 1316
I am trying to calculate the correlation between two different signals and it works perfect if the signals have the same size. But it gives an error if there size is different. So I am wondering if there is any way that I can change the size of one to the other so they can have the same size? Any Help??
As example:
If signal 1 is a matrix of size 130X9
and signal 2
is another matrix of size 122X12
and they look the same .. so what I need is to scale one of them to the other, so both of them can be of size 130X9
or 122X12
.
My code:
norm_xcorr_mag = @(x,y)(max(abs(xcorr(x,y)))/(norm(x,2)*norm(y,2)));
norm_xcorr_mag(signal1,signal2);
Upvotes: 1
Views: 94
Reputation: 4336
If you have signal processing toolbox
,
A = randi(100,[130 9]);
B = randi(100,[122 12]);
MaxRow = max(size(A,1),size(B,1));
MaxCol = max(size(A,2),size(B,2));
NewA = resample(A,MaxRow,size(A,1));
NewB = resample(B,MaxRow,size(B,1));
NewA = resample(NewA',MaxCol,size(A,2))';
NewB = resample(NewB',MaxCol,size(B,2))';
NewA
and NewB
are both 130x12
You could also try intrep1
.
Upvotes: 1