Plotting multiple lines on same graph
33 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dominique Davis
am 26 Nov. 2019
Kommentiert: Star Strider
am 27 Nov. 2019
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 Kommentare
Akzeptierte Antwort
Star Strider
am 27 Nov. 2019
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!