Unable to plot exponential graphs properly
显示 更早的评论
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?

采纳的回答
更多回答(1 个)
Alan Stevens
2021-9-12
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
