What does "a3.XTick" do to plot the cross-correlation on MATLAB ?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Star Strider
il 25 Apr 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 Commenti
Star Strider
il 1 Mag 2019
Thank you.
I no longer have access to that version, however finding the documentation online is easy enough.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Orange in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!