'How to use piecewise function within differential equations in MATLAB?
I'm struggling to use piecewise function in this pdpk model in MATLAB I keep getting the error of "Error using odearguments (line 113) Inputs must be floats, namely single or double.
Error in ode45 (line 106) odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);" Please help!
listed code below***
vnf = 1; qnf = 1; vf = 1; qf = 1;
vb = 1; pf = 20; vl = 1; ql = 1;
vmax = 1; Km = 1; pl = 2; pb = 18;
Ci = 0.32; % benzene conc in inhaled air
Qp = 5.74; % alveolar ventilation rate
conds = [0 0 0 0]; %--- initial conditions order: [NF F B L]
pul = piecewise(t > 6, 0, t <= 6, 1);
f = @(t,x) [qnf*(x(3)/vb - x(1)/vnf);...
qf*(x(3)/vb - x(2)/vf/pf);...
-qnf*(x(3)/vb - x(1)/vnf) - qf*(x(3)/vb - x(2)/vf/pf) - ql*(x(3)/vb - x(4)/vl/pl) + pul*Qp*(Ci - (x(3)/vb - pb));...
ql*(x(3)/vb - x(4)/vl/pl) - vmax*x(4)/vl/(Km + x(4)/vl)];
[t,x] = ode45(f, [0 10], conds);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
