The concentration of a drug in the body CP can be modeled by the equation:
where DG is the dose administered (mg), Vd is the volume of distribution (L), ka is the absorption rate constant (h-1), ke is the elimination rate constant (h-1), and t is the time (h) since the drug was administered. For a certain drug, the following quantities are given: DG = 150 mg, Vd = 50 L, ka = 1.6 h-1, ke = 0.4 h-1.
Assume a first dose is administered at t = 0, and subsequently four more doses are administered at intervals of 4 hours (i.e. at t = 4, 8, 12, 16). Write a MATLAB program to calculate and plot Cp versus t for 24 hours in increments of 0.1 hours. Use a for loop to calculate Cp for each time increment and add drug dosages at the appropriate times. Consider using a loop counter (e.g. k=k+1) to address the Cp array at each time increment (i.e. Cp(k)). To plot Cp versus t, you may need to create an array for the x-axis values (or time values).
Dg = 150;
Vd = 50;
ka = 1.6;
ke = 0.4;
This is what I've done so far
Cp = (Dg/Vd)*(ka/(ka-ke))*(exp(-ke * t)-exp(-ka * t))
title('Concentration over Time')
I have to use a for loop and I have to use a conditional. The error message I'm getting says "Variable Cp must be of size [1 241]. It is currentnly of size [1 1]. Check where the variable is assigned a value."