What does "a3.XTick" do to plot the cross-correlation on MATLAB ?

1 回表示 (過去 30 日間)
horizon
horizon 2019 年 4 月 25 日
コメント済み: Star Strider 2019 年 5 月 1 日
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]);

採用された回答

Star Strider
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 件のコメント
horizon
horizon 2019 年 5 月 1 日
My MATLAB version is R2017b.
Star Strider
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 Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by