Half life question in matlab
Show older comments
Metronidazole (used to treat infections) has a half life of H = 7.9 hours. Use solve to calculate [5 pt] the amount of time it takes for 50mg to decay to 20mg. Note that the decay constant is −ln(2)/H.
Can someone help me with the code that would be used to solve this type of problem?
Answers (2)
Star Strider
on 29 Jan 2015
1 vote
See the documentation for the solve function. The question itself has all the information you need otherwise. Particularly note ‘−ln(2)/H’.
The question assumes single-compartment kinetics for metronidazole, an anti-protozoal agent that is also active against C. dificile and some others.
6 Comments
Star Strider
on 29 Jan 2015
Bradley Sanchez’ ‘Answer’ moved here...
So would I just assign h as a variable with the value of 7.9. Then do solve(-ln(2)/h), in matlab.
Star Strider
on 29 Jan 2015
Well, only if you want to get the wrong answer!
‘Note that the decay constant is −ln(2)/H.’
The differential equation that describes single-compartment kinetics is:
dC(t)/dt = K*C(t)
that integrates to an exponential function, with K = -log(2)/H.
Half the initial concentration ‘C(0)’ will be eliminated in 7.9 hours. Since 20/50 is less than half, you already know that the concentration of 20mg is less than the half-life concentration of 25mg, so the time you will solve for will be greater than 7.9 hours.
Code up your equation, then use solve to find the solution the problem asks for.
If you have problems getting your code to work, post what you have here and we can help you get it running.
Bob
on 29 Jan 2015
Star Strider
on 29 Jan 2015
You have to put an equation of some sort in the argument to solve.
How would you calculate the clearance curve on paper with a calculator? How would you solve it for the time at which the concentration is 20mg? (That might be a good idea anyway, so you’ll know if your MATLAB code gives the correct result.) You have all the information you need.
The world will not end if your code doesn’t run the first time, or if it gives the wrong result. Please experiment with it.
Star Strider
on 30 Jan 2015
For the record, the solution to this problem is quite simply:
syms C(t)
H = 7.9;
K = -log(2)/H;
C(t) = exp(K*t);
t20s = solve(C == 20/50, t);
t20d = vpa(t20s, 3)
giving:
t20d =
10.4
So the concentration has reached the 20mg level at 10.4 hours.
noor iraq
on 10 May 2020
And if it with its Graph ?
Roger Stafford
on 29 Jan 2015
0 votes
Bradley, just ask yourself, "what power of 2 do I have to divide 50 by to get 20?". Then that power should be the ratio of the necessary decay time to 7.9 hours. It would be a very simple one-line matlab computation.
2 Comments
Roger Stafford
on 30 Jan 2015
If you discard that incorrect minus sign, you've already solved your problem without using 'solve'. They ought to give you extra credit for that.
If you are determined to use 'solve', then go back a step and write the equation you were trying to solve before you took the logarithm.
Categories
Find more on Numeric Solvers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!