Plotting multiple lines on same graph
35 ビュー (過去 30 日間)
古いコメントを表示
Hello! I am trying to plot multiple lines on the same graph but "hold on" is not working it is still printing as separate graphs. Some tips would help, thank you!
Code below.
clc;
t = linspace(0,1,1000);
yinitial = 5;
r1 = 5;
y1 = yinital * exp(r1*t);
figure, plot(y1)
hold on
r2= 10;
y2 = yinital * exp(r2*t);
figure, plot(y2)
0 件のコメント
採用された回答
Star Strider
2019 年 11 月 27 日
You created a second figure object, so the hold call did not apply to it.
You also misspelled ’initial’.
This works:
t = linspace(0,1,1000);
yinitial = 5;
r1 = 5;
y1 = yinitial * exp(r1*t);
figure, plot(y1)
hold on
r2= 10;
y2 = yinitial * exp(r2*t);
plot(y2)
The ‘r1’ plot is barely visible. Use semilogy insatead of plot to make both of them easily seen.
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!