Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
horizon
horizon le 25 Avr 2019
Commenté : Star Strider le 1 Mai 2019
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]);

Réponse acceptée

Star Strider
Star Strider le 25 Avr 2019
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 commentaires
horizon
horizon le 1 Mai 2019
My MATLAB version is R2017b.
Star Strider
Star Strider le 1 Mai 2019
Thank you.
I no longer have access to that version, however finding the documentation online is easy enough.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by