What and how to understand the math behind YYaxis syntax in MATLAB
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dear all, I am interested to know how does MATLAB under the syntax YYaxis was able to fitted two signals with different scales. For instant, in the documentation under the example Highway Data, MATLAB fitted perfectly the Licensed Drivers and Vehicle Miles Traveled.
Is it just a proportional fit such that using very simple convex optimization problem, where X = bY? I had tried to run the code line by line as it travel across different functions, however, unless I overlook, there was no specific line that show the fitting process between the signal/variables.
Do you mind to share what approach or technique that MATLAB used to get the common scale? I believe, by understand the principle behind it, we can further tune the code that suit our requirement.
Thanks in advance!.
The code for the said example as below
load('accidents.mat','hwydata')
ind = 1:51;
drivers = hwydata(:,5);
yyaxis left
scatter(ind,drivers)
title('Highway Data')
xlabel('States')
ylabel('Licensed Drivers (thousands)')
pop = hwydata(:,7);
yyaxis right
scatter(ind,pop)
ylabel('Vehicle Miles Traveled (millions)')
0 commentaires
Réponses (1)
Walter Roberson
le 6 Oct 2017
No fitting is done.
When you do not give a YLim (ylimit) then it is chosen automatically by searching for "nice" multiples involving the range. Roughly speaking, log10() of the max() minus the min() is taken, and that determines the power of 10 for the marks, with algorithm preferring ticks at multiples of 2, 5, or 10 within that range .
In the case of that example, the data just happens to line up neatly, suggesting that there might be a mathematical relationship between the two quantities.
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!