Info
This question is closed. Reopen it to edit or answer.
Regarding plot of cross correlation
2 views (last 30 days)
Show older comments
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 Comment
Answers (1)
Image Analyst
on 20 Oct 2012
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.
0 Comments
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!