How am I getting solutions to the ODE when I don't have a parameter defined?

1 view (last 30 days)
I was trying to produce a graph that plotted bacterial populations at a fixed time vs. the parameter called treatment. In an m-file, I had this so that I could use the ode45 solver :
function dX = ode(~,X,T)
bs = 8e-3; bl = 4e-3; bh = 6.4e-3; % per-capita growth rates of bacteria pop
N = sum(X); K = 1e8; % N-total population, K-carrying capacity
m1 = 2e-5; m2 = 9e-9; p = 5e-13; % mutation rates
I = 1e-3; % immune system clearing rate of bacteria
% T = 1e-3; % Treatment: I was told to comment this out
a = 0; % level of resistance to antibiotics
dX = [X(1) * (bs * (1 - N/K) - I - T - m1) - p * X(1) * (X(2) + X(3));
X(2) * (bl * (1 - N/K) - I - a*T - m2) + m1 * X(1) + p * X(2) * (X(1) - X(3));
X(3) * (bh * (1 - N/K) - I - a*T) + m2 * X(2) + p * X(3) * (X(1) + X(2))];
end
Then, in the command window, I type the following for-loop:
>> for treatment = 1e-4:1e-5:1e-3
[t,X] = ode45(@ode, [0 4.5e4], [1e4 0 0], [] , treatment);
plot(treatment,X(end,1), treatment,X(end,2), treatment,X(end,3))
xlabel('Treatment')
ylabel('Bacteria Population at 1 month')
legend('Sensitive', 'R. Low-Fitness', 'R. High-Fitness')
hold on
end
The point was to plot the bacterial population after one month of initial infection with different levels of treatment. The code kind of gives me a graph of what I wanted (I get dots when I wanted solid lines), but I don't see how the ode45 solver is working because I don't have T defined in my m-file. Can any of you tell me how the ode45 solver is still working even though it's solving the system that has an undefined parameter?

Accepted Answer

Star Strider
Star Strider on 26 Jul 2014
Edited: Star Strider on 26 Jul 2014
Interesting. I suspect t is provided primarily to allow the ODE function to use it in ODE functions that require it in the DEs themselves, and to define time-varying parameters, events, and such. In most ODE functions I’ve seen, the ODE functions don’t actually use t. I tested omitting it as an argument on another ODE that did not use t in its calculations, and it too integrated without error.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!