Filter löschen
Filter löschen

Issues with my Bifurcation Diagram

5 Ansichten (letzte 30 Tage)
Emily Tabb
Emily Tabb am 26 Mai 2021
Kommentiert: Star Strider am 26 Mai 2021
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 Kommentare
Torsten
Torsten am 26 Mai 2021
Bearbeitet: Torsten am 26 Mai 2021
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 am 26 Mai 2021
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

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 26 Mai 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 Kommentare
Emily Tabb
Emily Tabb am 26 Mai 2021
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 am 26 Mai 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by