필터 지우기
필터 지우기

What and how to understand the math behind YYaxis syntax in MATLAB

조회 수: 1 (최근 30일)
balandong
balandong 2017년 10월 6일
댓글: balandong 2017년 10월 6일
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)')

답변 (1개)

Walter Roberson
Walter Roberson 2017년 10월 6일
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.
  댓글 수: 1
balandong
balandong 2017년 10월 6일
Hi Walter,
Thanks for the insight!
As you can see in the following figure (tqken from Figure link), there are totally two different scale for the left and right Y-axis. My best guest, some scaling factor must take place to squeeze or enlarge the blue and orange lines, respectively.
May I know what exactly do you mean by MATLAB " chosen automatically by searching for "nice" multiples involving the range" . What process has been automated?
Really appreciate for your wisdom.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by