Filter löschen
Filter löschen

2-x axes and 1-y axis

7 Ansichten (letzte 30 Tage)
Mohammed Qahosh
Mohammed Qahosh am 6 Jun. 2019
Kommentiert: dpb am 7 Jun. 2019
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 Kommentare
Mohammed Qahosh
Mohammed Qahosh am 6 Jun. 2019
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 am 6 Jun. 2019
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jos (10584)
Jos (10584) am 6 Jun. 2019
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 Kommentare
dpb
dpb am 7 Jun. 2019
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 am 7 Jun. 2019
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...

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Two y-axis finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by