2-x axes and 1-y axis

4 ビュー (過去 30 日間)
Mohammed Qahosh
Mohammed Qahosh 2019 年 6 月 6 日
コメント済み: dpb 2019 年 6 月 7 日
I would like to plot a figure having two x-axes at the bottom and the top of the figure, and one y-axis at the left of the figure.
I did an experiment where I am finding the relation between Intensiy and (time or temperature)
So I would like to have the time on the bottom x-axis and the corresponding temperature on the top x-axis. Where the intensity is common for both on the left y-axis.
Data as an example:
% Time in seconds
Time=[1 2 3 4 5 6 7 8 9 10]
Temperature=[23 10 0 -5]
Intensity=[2 2 4 3 7 9 5 6 8 2]
% where the temperature readings correspond to Time=[1 4 7 10] and Intensity=[2 3 5 2]
  7 件のコメント
Mohammed Qahosh
Mohammed Qahosh 2019 年 6 月 6 日
No. In fact the y-axis is the Intensity.
So, I am talking about the top x-axis (Temperature). I want it to be decreasing while moving to the right starting from 23 and ending with -172
dpb
dpb 2019 年 6 月 6 日
Then just reverse the direction for it...
hAx(2).XDir='reverse';
where hAx(2) is the handle to the second x-axis, presumed to be the target desired. You'll have to use whatever handle is the correct variable in your code that we've seen none for--hence the guessing about what you're trying to accomplish.
Or, of course, you can set addtiional parameters at the time you create the axes itself.

サインインしてコメントする。

回答 (1 件)

Jos (10584)
Jos (10584) 2019 年 6 月 6 日
What about 'abusing' plotyy?
x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
plotyy(x, y1, x, y2)
view(90, 90) % a single axis on the left, and two axes on top and bottom
  10 件のコメント
dpb
dpb 2019 年 6 月 7 日
Actually, I have a limited number of readings corresponding to {Temperature,Intensity}.
While I have thousands for {Time,Intensity} and I am gothering them together from seperate videos.
So I can reverse the data on the top x-axis easily.
Thank you very much!
dpb
dpb 2019 年 6 月 7 日
It still shouldn't make any difference at all how many variables there are -- the reverse direction is a property of the axis, not the data. Set it once and it's set for good...
We've possibly got a language barrier here in not following what you're trying to express...

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeTwo y-axis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by