Info

此问题已关闭。 请重新打开它进行编辑或回答。

Regarding plot of cross correlation

3 次查看(过去 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