Code covered by the BSD License  

Highlights from
RGDS_Practical_Guide

image thumbnail

RGDS_Practical_Guide

by

 

15 Mar 2013 (Updated )

MATLAB routines for the book: "Development of Innovative Drugs via Modeling with MATLAB".

PK1IV1b
function PK1IV1b
%PK1IV1B Simultaneous calculation of drug amounts and concentrations.
%   PK1IV1B calculates drug amounts and drug concentrations for
%   a one-compartment PK model with IV input and first-order
%   elimination. The second equation defined in PK1IVb is treated 
%   as algebraic equation by using the Mass option in odeset.        

clear; clc; close all;
p.V = 5.0;      % L   
p.k10 = 1.0;    % mg/h
dose = 100;     % mg 
timeEnd = 10;   % h

options = odeset;
options.Mass = [1 0; 0 0];

[t, y] = ode15s(@derivalgeb,[0 timeEnd],[dose; dose/p.V],options,p);
a = y(:,1);
c = y(:,2);
plot(t,a,'-r',t,c,'b-','lineWidth',2)
legend('Drug amounts [mg]','Drug concentrations [mg/L]')
xlabel('Time [h]')
ylabel('Value')
    
end 	


function dydt = derivalgeb(~, y, p)
%DERIVALGEB Compute the right-hand side of the DAE.
%   MDYDT = DERIVALGEB(T, Y, P) calculates |DYDT|, the right-hand
%   side of the DAE model at points defined by the vector of
%   dependent variables |Y|, time |T|, and with parameters |P|. 
%   The right-hand side represents both the differential equations 
%   and algebraic equations.

a1   = y(1);
c1   = y(2);
da1  = - p.k10*a1;   % ode 
dc1  = c1 - a1/p.V;  % algebraic equation: dc1 = 0
dydt = [da1; dc1];
    
end


Contact us