
Adding a second scaled y-axis to a plot
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Christian Nørgaard
le 25 Mai 2018
Commenté : Ameer Hamza
le 25 Mai 2018
Hello,
I have been trying to figure out how to add a second scaled y-axis ( or even just a second y-axis) and even after reading through several Matlab forum posts it still does not work. I was wondering if anyone out there, would help me figure out what I am doing wrong.
My personal thoughts on what is wrong is something to do with the fact that I am trying to plot a curve fit on a set of data and when I tell Matlab to plot according to some x-axis is can not compute my request.
My matlab code so far:
x=[
0
3
6
9
11.5
13.952
];
y=[
0.905
0.900
0.850
0.800
0.788
0
];
v=[
0
3
6
9
11.5
13.952
];
p=[
0
2.5
5.1
8.9
11.493
0
];
f=fit(v,p,'poly5')
c=fit(x,y,'exp2')
figure(1)
plot(f)
figure(2)
x= 0: 1.0 : 15;
plot(f);
hold on;
plot(c)
Where x,y are plots for one curve and v,p (x and y coordinates respectivly) for the other curve
I have tried,
x= 0: 1.0 : 15;
plot(x,f);
hold on;
plot(x,c)
and I tried to follow the example given in https://se.mathworks.com/matlabcentral/answers/23591-examples-of-multiple-plots-on-one-graph ( more specifically the accepted answer given by Chandra Kurniawan) , where a problem similar to what I am facing now was asked and answered.
Any help/thoughts/advice is extremely welcome! Thank you in advance
0 commentaires
Réponse acceptée
Ameer Hamza
le 25 Mai 2018
You can use yyaxis to plot 2 axis
x = 0:0.1:10;
yyaxis left
plot(x, x);
yyaxis right
plot(x, sin(x))

6 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with Curve Fitting Toolbox 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!