hold on producing separate graphs
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
hold on
figure
x = I
y1 = 4*I.^20
hold on
plot(x,y1)
figure
x = I
y2 = 4*I.^1
hold on
plot(x,y2)
figure
x = I
y3 = 4*I.^0.3
hold on
plot (x,y3)
Here is my code for the three lines I want to plot on the same graph, however it is producing 3 separate graphs, I wondered how I can edit this to ensure it plots the three lines on one graph?
Thank you
0 Kommentare
Akzeptierte Antwort
VBBV
am 11 Dez. 2022
I = 1:10;
figure
x = I
y1 = 4*I.^2
hold on
plot(x,y1)
% figure
x = I
y2 = 4*I.^1
hold on
plot(x,y2)
% figure
x = I
y3 = 4*I.^0.3
hold on
plot (x,y3)
2 Kommentare
VBBV
am 11 Dez. 2022
Its better to use subplot when you have values on lines which differ by significantly high
I = 1:10;
subplot(311)
x = I
y1 = 4*I.^20 % this ^ 20 is huge number !
plot(x,y1)
y2 = 4*I.^1
subplot(312)
plot(x,y2)
y3 = 4*I.^0.3
subplot(313)
plot (x,y3)
Weitere Antworten (1)
KALYAN ACHARJYA
am 11 Dez. 2022
Bearbeitet: KALYAN ACHARJYA
am 11 Dez. 2022
Remove all "figure" statements, also one hold on is sufficient.
Same Figures:
x = I
y1 = 4*I.^20
hold on
plot(x,y1)
x = I
y2 = 4*I.^1
plot(x,y2)
x = I
y3 = 4*I.^0.3
plot (x,y3)
0 Kommentare
Siehe auch
Kategorien
Mehr zu 2-D and 3-D 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!