![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/174620/image.jpeg)
How to plot second y axis y2 that is just related to y1 as f(y1)
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a plot on y1 axis. I would like to have units conversion on axis y2, as f(y1).
How can you plot two units on one graph ? That will assume that horizontally the unit conversion is correct.
Thank you.
x = linspace(0.1,20,100);
y1 = x.^2;
y2 = x^.4./2x; % for example unit conversion for y2 axis no graph to plot
plot(x,x.^2)
0 commentaires
Réponses (1)
dpb
le 1 Juil 2016
plotyy is about the simplest; it computes "nice" axes limits automagically that line up over the ranges of the two axes--
y2 = x.^.4./(2*x);
plotyy(x,y1,x,y2)
legend('y1','y2','location','best')
yields the following:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/174620/image.jpeg)
0 commentaires
Voir également
Catégories
En savoir plus sur Two y-axis dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!