Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Regarding plot of cross correlation

1 回表示 (過去 30 日間)
kavya saxena
kavya saxena 2012 年 10 月 20 日
Hi all, please check it out. It's urgent
I'm doing cross correlation of two column vector using xcorr() function. My code is
time=data(:,1);
>> ux1=data(:,2);
>> ux2=data2(:,2);
>> cc=xcorr(ux1,ux2);
>> plot(time,cc);
it gives an error that vectors must be same length. then i did
>> n=length(time);
>> r=cc(1:n);
>> plot(time,r);
it does not gives a peak value, then i again did
>> plot(time,abs(r));
>> y=max(abs(r))
It gives the plot having one peak but I'm not sure that it is correct, becoz the time at peak value is not matching with my theoretical value.

回答 (1 件)

Image Analyst
Image Analyst 2012 年 10 月 20 日
Do this
length(time) % No semicolon
length(cc) % No semicolon
and see what they print in the command window. They will be different lengths because the correlated signal's length is the sum of the two signals lengths minus 1. Try this:
plot(cc, 'bo-');
Why do you think there are more elements in cc than time? How do you think you need to construct a new time array so that it's the same length? What element of the new array corresponds to element 1 of the old time array? Maybe you should try some simple correlations by hand with like 5 elements and see what happens. It will be instructive.

この質問は閉じられています。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by