# How do I plot an equation with multiple Iterations.

19 visualizzazioni (ultimi 30 giorni)
Heather Worth il 2 Feb 2022
Risposto: Robert U il 2 Feb 2022
I need to plot the 500 iterations versus the iteration numbers, but with the code I'm using, it just gives me a blank graph.
lambda=6.544;
x0=0.65;
N=500;
for i=1:N
x1=lambda*(x0^2)*(1-x0);
x0=x1;
end
plot(N,x1)
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (1)

Robert U il 2 Feb 2022
Hi Heather Worth,
you can store x1 each iteration in a vector and plot the vector at the end of the calculation.
lambda=6.544;
x0=0.65;
N=500;
for ik=1:N
x1(ik) = lambda*(x0^2)*(1-x0);
x0 = x1(ik);
end
plot(1:N,x1,'.','MarkerSize',12)
Or you can plot each iteration on the fly.
lambda=6.544;
x0=0.65;
N=500;
fh = figure;
ah = axes;
hold(ah,'on');
for ik=1:N
x1 = lambda*(x0^2)*(1-x0);
x0 = x1;
plot(ah,ik,x1,'bl.','MarkerSize',12)
end
Kind regards,
Robert
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### 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!

Translated by