Azzera filtri
Azzera filtri

Issues with my Bifurcation Diagram

5 visualizzazioni (ultimi 30 giorni)
Emily Tabb
Emily Tabb il 26 Mag 2021
Commentato: Star Strider il 26 Mag 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 Commenti
Torsten
Torsten il 26 Mag 2021
Modificato: Torsten il 26 Mag 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 il 26 Mag 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

Accedi per commentare.

Risposte (1)

Star Strider
Star Strider il 26 Mag 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 Commenti
Emily Tabb
Emily Tabb il 26 Mag 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 il 26 Mag 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.

Accedi per commentare.

Categorie

Scopri di più su Programming in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by