Issues with my Bifurcation Diagram

5 次查看(过去 30 天)
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 个评论
Torsten
Torsten 2021-5-26
编辑:Torsten 2021-5-26
Maybe somebody can help if you report the complete error message.
You will have to plot c against t, not c against k.
Emily Tabb
Emily Tabb 2021-5-26
i need to plot c against k, as it is in the equation and is the parameter that i am changing, will it be better if i just remove t?
Error was probably the wrong word, the code completes but when the figure presents itself there is nothing on it, there is no graph on it at all

请先登录,再进行评论。

回答(1 个)

Star Strider
Star Strider 2021-5-26
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 个评论
Emily Tabb
Emily Tabb 2021-5-26
Thankyou so much for you're help I'm not sure why it is not looking more like a bifurcation diagram is there a major issue you can see in the coding? I'm just trying to plot a bifurcation diagram from this equation dc/dt = 1/10(C-23)(25-C)(C-29) - k
Thanks
Star Strider
Star Strider 2021-5-26
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by