Unable to plot exponential graphs properly
Afficher commentaires plus anciens
I want to plot multiple simple exponential graphs in a single graph. At one time, I don't know how I got the correct plot, but later when I have copied the same plot multiple times and still unable tot get the desired results.
t = linspace(-10,10,400); y1 = exp(t); plot(t,y1) hold on t = linspace(-10,10,400); y2 = exp(-t); plot(t,y2) hold on t = linspace(-10,10,400); y3 = exp(2*t); plot(t,y3) legend('y1','y2','y3'). I have attached the unexpected results that I am getting. How can I make it work?

Réponse acceptée
Plus de réponses (1)
Alan Stevens
le 12 Sep 2021
One possibility
t = linspace(-10,10,400);
y1 = exp(t);
y2 = exp(-t);
y3 = exp(2*t);
plot(t,y1,t,y2,t,y3)
legend('y1','y2','y3')
though you would be better off plotting them using separate graphs (see subplot) because of the scaling differences.
Catégories
En savoir plus sur Annotations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
