필터 지우기
필터 지우기

Issues with my Bifurcation Diagram

조회 수: 5 (최근 30일)
Emily Tabb
Emily Tabb 2021년 5월 26일
댓글: Star Strider 2021년 5월 26일
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