Need help solving this question in MATLAB

Question:
A drug is encapsulated in a polymerand then released slowly into the bloodstream of patients. 100𝜇𝑔 of a drug in a controlled release capsule is injected into a patient. The drug is released at a rate of 8e^(-0.1t^2) 𝜇𝑔/ℎ , where t is hours after injection. Use Matlab toolbox to calculate what fraction of the drug remains in the capsule after 24 h?
I was thinking of using the ode45 solver to solve for the amount of drug remaining in the capsule when t = 24 as shown:
Function File:
function f=Assignment2Q3(D,t)
f=8*exp(-0.1*(t^2));
end
Command Window:
[D,t]=ode45('Assignment2Q3',[0:24],100);
However I have run into 2 problems.
Firstly, the solver does not seem to be working as intended, as I am getting values of D=100 (D is the variable im defining for the amount of drug left in the capsule) for every value from t=0 to t=24.
Next, I do not know how to code the 2nd part of the function that would return me the fraction of the drug in the capsule after 24h after obtaining the value for D when t=24.
A step by step method that details what is being done at each step would be appreciated, as I am very new to MATLAB. Thank you!

 Accepted Answer

Isn't just an integration of the rate?
f=@(t)8*exp(-.1*t.^2);
FractionRemaing=(100-integral(f,0,24))/100
FractionRemaing = 0.7758

1 Comment

yep, that pretty much summarizes it. Thanks a lot for your help!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!