(adsbygoogle = window.adsbygoogle || []).push({}); 1. The problem statement, all variables and given/known data

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.

2. Relevant 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.

3. 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)

**Physics Forums - The Fusion of Science and Community**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Matlab - I am having problems with iteration (loops)

Loading...

Similar Threads - Matlab having problems | Date |
---|---|

Matlab Does MatLab have this kind of function? | Jan 15, 2017 |

Matlab -- how can i use a FOR loop if I have 2 variables changing | Oct 12, 2016 |

So I have another matlab problem | Apr 4, 2007 |

Having a problem with solving a second order ODE equation using Matlab | Feb 14, 2007 |

Having a problem with soling a second order ODE equation using Matlab | Feb 14, 2007 |

**Physics Forums - The Fusion of Science and Community**