- #1
rad0786
- 188
- 0
Homework Statement
Hi. I sort of doubt that anyone will reply to this post since it is a MATLAB problem, but ill give it a shot.
I am trying to write a MATLAB function that will graph the logistic map.
Homework Equations
x(n+1) = r*xn*(1-xn) (1)
The inputs are r, x0 and N.
I want the function to store the sequence x1, x2, . . . , xN given by (1) as the components of a vector x and plots them with respect to n.
The Attempt at a Solution
function [x_i+1]=logistic_map(r,x0,N)
% [x]=logistic_map(r,x0,N)
% the initial condition is x0
% x depends on scalars r, x0, N
% the function computes xn+1 = r*xn(1-xn)
for i = 1:N
x_i+1 = r*x0*(1-x0)
end
plot(1:N,x_i+1)