when i plot a function, others disappear
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
When i write the code below, matlab does not plot all the functions but one. you can see what i mean. Where did i make a mistake? Thank you for upcoming helps.
t = [-5:0.1:10];
x = t.^3 - 2*t + 9;
y = 6*t.^5 - t;
z = t.^2 + 7;
plot(t,x,'r:')
hold on
plot(t,y,'g--')
hold on
plot(t,z,'b-.')
hold off
0 Commenti
Risposte (1)
the cyclist
il 10 Apr 2022
Modificato: the cyclist
il 10 Apr 2022
All three lines are being plotted. The issue is that the green line goes to huge values, so you don't see the separation between the other two. Here, I've plotted over a much smaller range, so you see that:
t = [-1.5:0.01:1.5];
x = t.^3 - 2*t + 9;
y = 6*t.^5 - t;
z = t.^2 + 7;
plot(t,x,'r:')
hold on
plot(t,y,'g--')
hold on
plot(t,z,'b-.')
hold off
FYI, you don't need to repeatedly use hold on ...
t = -1.5:0.01:1.5
x = t.^3 - 2*t + 9;
y = 6*t.^5 - t;
z = t.^2 + 7;
figure
hold on
plot(t,x,'r:')
plot(t,y,'g--')
plot(t,z,'b-.')
hold off
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!