What does "a3.XTick" do to plot the cross-correlation on MATLAB ?
1 次查看(过去 30 天)
显示 更早的评论
This is the sample program from MATLAB Documentation for xcorr and I'm troubled with understanding why the scale "-3000:1000:3000" is requred for the plot of the cross-correlation.
Moreover, I cannot understand why sort function is used in this case.
There was no discription of sort([-3000:1000:3000 lagDiff]) the MATLAB Documentation which explains sort function .
I would appreciate if you explain the meaning of each element, [], -3000:1000:3000, and lagDiff in this case, and how these are sorted.
load sensorData
t1 = (0:length(s1)-1)/Fs;
t2 = (0:length(s2)-1)/Fs;
subplot(2,1,1)
plot(t1,s1)
title('s_1')
subplot(2,1,2)
plot(t2,s2)
title('s_2')
xlabel('Time (s)')
[acor,lag] = xcorr(s2,s1);
[~,I] = max(abs(acor));
lagDiff = lag(I)
timeDiff = lagDiff/Fs
figure
plot(lag,acor)
a3 = gca;
a3.XTick = sort([-3000:1000:3000 lagDiff]);
0 个评论
采纳的回答
Star Strider
2019-4-25
This assignment:
a3.XTick = sort([-3000:1000:3000 lagDiff]);
sets the 'XTick' values of the current axes (denoted here by ‘a3’) to be the sorted vector so that the ‘lagDiff’ value (350) appears within the vector in the appropriate place with respect to the other elements.
(What version of the documentation is that taken from? I can run the example, however I cannot find it in the current documentation for R2019a.)
2 个评论
Star Strider
2019-5-1
Thank you.
I no longer have access to that version, however finding the documentation online is easy enough.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Orange 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!