Modelling a system of ODEs and need to add inputs after t=0?

6 views (last 30 days)
Hi all,
I'm testing a pharmacokinetic model in MATLAB, it's very stiff so I'm currently using ode15s, the system is comprised of 7 interconnected ODEs representing various 'compartments' within the body.
My issue is as follows: I'm attempting to forward model the system based on a fitted parameter set, in order to model is accurately I need to mimic the inputs as done in the original in vivo trials. There in one input at t=10s and two further inputs at t=60s.
I've attempted a work around, just attempting to brute force it in the function but that led the solver to complain about infinitely small step sizes so I assume I broke something.
Any suggestions would be fantastic! Thank you.

Accepted Answer

Star Strider
Star Strider on 24 Apr 2020
I am not exactly certain what you are doing or what your pharmacokinetic model is. Not knowing more, I would do something like this (assuming ‘t’ is the time vector and the integrated values are stored in matrix ‘y’):
Use first set of initial conditions ‘ic’
tspan = linspace(0, 10, 10);
Run ode15s with your ODE function
ic = y(end,:);
t0 = t(end);
ic(appropriate_compartment) = dose(1);
Use new set of initial conditions ‘ic’
tspan = linspace(t0, t0+60, 60);
Run ode15s with your ODE function
ic = y(end,:);
t0 = t(end);
ic(appropriate_compartment) = dose(2);
... continuing for as many steps as necessary. Adjust the number of elements in ‘tspan’ with the third argument of linspace. You will need to vertically concatenate the ‘t’ vectors and ‘y’ matrices from each step (loop iteration) to create the complete simulation.
I’m simply sketching this, corresponding to similar problems I’ve worked on.
Apparently the SimBiology has a set of functions that will make alll this straightforward, although I have no experience with it. (I don’t do such simulations frequently enought to justify buying it.)
  8 Comments
Star Strider
Star Strider on 25 Apr 2020
Thank you!
I understand. If at some point you’d like my help in solving it, post back here with the model and the data and I’ll do my best to identify it correctly and simulate it.
In the interim, see: Parameter Estimation for a System of Differential Equations. That’s likely the most concise of such posts. There are others, including some that use the ga (genetic algorithm) to estimate the parameters.
Sietse Braakman
Sietse Braakman on 1 May 2020
Hi Daniel,
One of the problems you are running into is the fact that you need to restart the ODE solver, every time you dose/perturb the model. SimBiology can really help here, as it takes care of the ODE solver restarts and makes dosing much easier. The function sbiofit (or a fit program in the Model Analyzer App) will allow you to set up parameter estimations easily and iterate through different algorithms, try out different error models. Primarily, it constructs the objective function for you.
PM me if this is of interest - I can help you get started with SimBiology.
Best,
Sietse

Sign in to comment.

More Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!