Plotting from a for loop- discrete maps

5 visualizaciones (últimos 30 días)
Maria Raheb
Maria Raheb el 26 de Mzo. de 2020
Comentada: Maria Raheb el 27 de Mzo. de 2020
I'm just playing around with discrete maps (i.e. the logistic map). I seem to be having an issue plotting my data; It seems to only plot the last data point. Any suggestions?
function [x] = logistic(lambda,x0,n)
x(1) = x0;
for i= 1:n
x(i+1) = lambda*x(i)*(1-x(i));
z = [i,x(i)];
disp(z);
end
plot(z,'+');
end
Thank you in advance

Respuesta aceptada

Birdman
Birdman el 27 de Mzo. de 2020
function [x] = logistic(lambda,x0,n)
x(1) = x0;
for i= 1:n
x(i+1) = lambda*x(i)*(1-x(i));
z(i,:) = [i,x(i)];
disp(z);
end
plot(z(:,1),z(:,2),'+');
end
  1 comentario
Maria Raheb
Maria Raheb el 27 de Mzo. de 2020
Thank you!
Any idea how I can use my code to construct a bifurcation diagram of the quadratic/logistic map? The code I've attached does not do that for me.
for lambda = 0:0.01:4
[x] = logistic(lambda,0.5,25);
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by