Issues with my Bifurcation Diagram
5 views (last 30 days)
Show older comments
My code is completing but will not graph any data and i'm not sure why, I need to plot k againct c as my parameters
Can anyone else see the problem
thankyou
figure;
ax(1);
hold on
xlabel ('k');
ylabel ('C');
xlim([-2 2]);
ylim([0 40]);
dt = 0.01;
N = 10000;
for k=-2:0.1:10
c = zeros(N,1);
c(1)= 23;
t(1) = 0;
for i=1:N
t(i+1) = t(i) + dt;
c(i+1) = c(i) + dt*((1/10)*((c(i)-23)*(25-c(i))*(c(i)-29))-k);
end
plot(ax(1),k,c,'color','blue','marker','.');
end
2 Comments
Answers (1)
Star Strider
on 26 May 2021
One problem is that ‘ax(1)’ does not have anything assigned to it, at least in the posted code. Fixing that makes the axes magickally appear!
Beyond that, the code takes a while to run, so I changed ‘N’ to a value that does not time-out the online Run feature 55 second limit. It does not look like a bifurcation diagram, but at least now it plots.
figure;
ax(1) = axes;
hold on
xlabel ('k');
ylabel ('C');
xlim([-2 2]);
ylim([0 40]);
dt = 0.01;
N = 250;
for k=-2:0.1:10
c = zeros(N+1,1);
c(1)= 23;
t(1) = 0;
for i=1:N
t(i+1) = t(i) + dt;
c(i+1) = c(i) + dt*((1/10)*((c(i)-23)*(25-c(i))*(c(i)-29))-k);
end
plot(ax(1),k,c,'color','blue','marker','.');
end
.
2 Comments
Star Strider
on 26 May 2021
My pleasure!
I have no idea, although I suspect there is more to the equation tthan was posted.
My Answer specifically addresses the plotting problem.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!