How can I plot graph in this relationship?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm trying to plot graph of relations of (j,s) in this for script.
s=0;
for j=1:1:10
s=s+j;
disp(['j = ', num2str(j)] );
disp(['s = ', num2str(s)] );
plot(j,s)
end
however, nothing appears when I try to plot it. What's the problem with it? And how can I plot graph of the relationship between (j,s)?
0 Kommentare
Akzeptierte Antwort
Torsten
am 31 Okt. 2023
Bearbeitet: Torsten
am 31 Okt. 2023
s=0;
hold on
for j=1:1:10
s=s+j;
disp(['j = ', num2str(j)] );
disp(['s = ', num2str(s)] );
plot(j,s,'b o')
end
hold off
1 Kommentar
Torsten
am 31 Okt. 2023
It's more common to compute all values for s in advance and make the plot afterwards:
x = 1:10;
s = cumsum(x);
plot(x,s,'b o')
Weitere Antworten (0)
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!

