How to plot a graph with a set of updated values from the for loop?

1 Ansicht (letzte 30 Tage)
Ancy S G
Ancy S G am 17 Feb. 2022
Kommentiert: Ancy S G am 18 Feb. 2022
I have to plot a graph with number of iterations on the x axis and the updated values for each iterations(ie, set of values) in y axis.How to plot this?

Antworten (1)

Voss
Voss am 17 Feb. 2022
It might be something like this:
ii = 1;
x = 1;
y = 1;
while ii < 10
x(ii+1) = x(ii)+1;
y(ii+1) = y(ii)*2;
ii = ii+1;
end
plot(1:ii,x,'-x');
hold on
plot(1:ii,y,'-o');
legend('x','y');
xlabel('Iteration No.');

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by