% MATLAB program for iterating the logistic map
% and making a bifurcation plot -- r vs x_inf
clear; clc % Clear variables and matlab command windo
close all % Close any open plot windows
Nr = 2500; % Number of different values of r to include
r_a = 0; % lower bound on r range
r_b = 3.5; % upper bound on r range
r = linspace(r_a, r_b, Nr); % Assign the values of r
Nskips = 1000; % Number of iterations to skip (avoid transient
% in plot)
Nsteps = 500; % Number to include in plot (after transient has
% died away)
data = zeros(Nsteps,Nr); % Store the points to plot in this
% array
for i_r = 1:Nr % loop over r values
x = .1; % Starting value, (almost) anything works
for i_st = -Nskips+1:Nsteps % loop over i
x = r(i_r)*x*(1-x); % Compute next x
if i_st > 0 % Only record data after the transient has died away
data(i_st,i_r) = x;
end
end
end
plot(r,data,'b.','MarkerSize',1)