% MATLAB program for iterating the logistic map
close all % Close any open plot windows
clear; clc % Clear all variables, clear the command line
Nsteps = 20; % Change this number to add more steps (more iterations)
x = zeros(1,Nsteps); % Initilize the 'x' array (make it empty)
x(1) = .2; % Change this number to change the starting value
r = 2.7; % This is the rate of reproduction (should be between 0 & 4)
% This part of the program iterates the equation (the "logistic map")
for i = 1:Nsteps-1
x(i+1) = r*x(i)*(1-x(i));
end
% Makes a plot of our results
plot(1:Nsteps,x,'.-')