In: Computer Science
The equation A = Ao * e^(-t(log2/h)) is used to model the decay of radioactive materials. Where A is the amount of material at time t, A0 is the amount at time 0 and h is the half-life.
Write a program that prompts for a decay time and how long of an interval you want to look at. Then write the code that creates a table with the appropriate information.
For example, the decay rate is 6 months for material xyz. What does it look like over 30 hours?
Matlab code:
days = input('Entert the number of days you want to look
at\n');
A_0 = 1000; % let initial mass of the element is 1000 gm
h = 10; %let half_life of the element is 10 days
for i = 1:days
fprintf('Remaining mass after %d days is %d gm\n', i,A_0 * exp(-i
*( log(2)/h )));
end
Sample Output:
Remaining mass after 1 days is 933.033 gm Remaining mass after 2 days is 870.551 gm Remaining mass after 3 days is 812.252 gm Remaining mass after 4 days is 757.858 gm Remaining mass after 5 days is 707.107 gm Remaining mass after 6 days is 659.754 gm Remaining mass after 7 days is 615.572 gm Remaining mass after 8 days is 574.349 gm Remaining mass after 9 days is 535.887 gm Remaining mass after 10 days is 500 gm Remaining mass after 11 days is 466.516 gm Remaining mass after 12 days is 435.275 gm Remaining mass after 13 days is 406.126 gm Remaining mass after 14 days is 378.929 gm Remaining mass after 15 days is 353.553 gm Remaining mass after 16 days is 329.877 gm Remaining mass after 17 days is 307.786 gm Remaining mass after 18 days is 287.175 gm Remaining mass after 19 days is 267.943 gm Remaining mass after 20 days is 250 gm