Calculating growth using ODE 45 from t=0 to t=100
1 view (last 30 days)
Show older comments
Hello, I need help with my code using ODE 45. Can someone help me check my code?
t = 0:0.01:100;
r = [0.05 0.1 0.5 1 10];
k = 15;
B0 = 1;
B = @(x,y) 30-x.^2-5*(cos((x.*y)/5)).^2;
colourmap = [228 26 28; 55 126 184; 77 175 74; ...
152 78 163; 255 127 0]/255;
z = zeros(length(t),length(r));
T = zeros(length(t),length(r));
%
for i = 1:length(r)
dBdt = @(B) r.*B*(1-B./k);
[z,T] = ode45(dBdt,tspan, B0);
plotting
figure(6) %figure 6
loglog(t,T,'-','color',colourmap(i,:))
hold on
grid on
end
1 Comment
Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!