Create Logistic Map M-File in MATLAB

• MATLAB
• lahuxixi
In summary, the conversation is about creating an m-file to display the behavior of the logistic map for different values of r using a bifurcation diagram. The individual is having trouble with their code and is seeking help to fix it. The expert suggests using a nested for loop to ensure that different values of y are plotted for each value of c.
lahuxixi
I want to make a m-file that show the behavior of the logistic map for di erent values of r using the bifurcation diagram.
This is what i currently have, but i don't know why it is wrong.
Can anyone help me?

c=0;
hold on
while c < 4
y=0.5;
for i=1:100;
y = -c*y^2 +c*y; %converge the iteration
end
for i=1:20
y = -c*y^2 +c*y;
plot(c,y,'.', 'MarkerSize',1); % plot the converged points
end
c=c+0.002;
end

hold off

Hello,

Thank you for sharing your code. From a quick glance, it seems like the issue may be with your for loop. In the first loop, you are converging the iteration, but in the second loop, you are using the same value of c for each iteration. This means that you are plotting the same point multiple times, instead of plotting the different values of y for each value of c.

To fix this, you can try modifying your code to use a nested for loop, where the outer loop iterates through different values of c, and the inner loop converges the iteration and plots the points for that specific value of c. This way, you will have a different value of y for each value of c, and your bifurcation diagram will show the behavior of the logistic map for different values of r.

I hope this helps. Good luck with your project!

1. What is a logistic map in MATLAB?

A logistic map in MATLAB is a mathematical function that models the population growth of a species based on a logistic equation. It is commonly used in population ecology and can also be applied to other systems that exhibit similar growth patterns.

2. How do you create a logistic map in MATLAB?

To create a logistic map in MATLAB, you can use the built-in "logistic" function that takes in parameters such as the initial population size, growth rate, and carrying capacity. Alternatively, you can write your own custom function using the logistic equation: Xn+1 = r*Xn*(1-Xn), where r is the growth rate and Xn is the current population size.

3. What is the purpose of creating a logistic map in MATLAB?

The purpose of creating a logistic map in MATLAB is to model and analyze the population growth of a species or system. This can help in understanding the dynamics and predicting future trends of the population.

4. What are some applications of logistic maps in MATLAB?

Logistic maps in MATLAB can be used in various fields such as biology, economics, and physics. They can help in studying population dynamics, analyzing market trends and forecasting, and understanding chaotic systems.

5. Are there any limitations to using logistic maps in MATLAB?

Yes, there are some limitations to using logistic maps in MATLAB. They are based on simplifying assumptions and may not accurately represent complex systems. Additionally, the accuracy of the results depends on the accuracy of the initial parameters and can be affected by small changes in the values.

Replies
8
Views
647
Replies
5
Views
2K
Replies
4
Views
1K
Replies
1
Views
1K
Replies
14
Views
3K
Replies
2
Views
1K
Replies
2
Views
3K
Replies
9
Views
4K
Replies
18
Views
3K
Replies
4
Views
1K