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 CenterFile Exchange에서 2-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