How to use Eulers Algorithm to solve half life decay on matlab
Show older comments
clc; clear all;
n = 100; % Number of iterations / decays
N = 1:n+1; % Array containing 100 elements
N0=1000; % Initial number of atoms
N(1)= N0; % First element in array N or initial number of atoms
time(1)=0;
tau = 1.0;
Delta = 0.02;
for i=1:n+1 % Compute the remaining atoms after each time
N(i+1)=N(i)-Delta*N(i)/tau % Euler algorithm for decay process.
time(i+1)=i*Delta
end
ms = 1.5;
figure(1);
plot(time,N,'-ob','Markersize',ms);xlabel('Time(s)'); ylabel('Number of atoms');
Im trying to use the algorithm above to write a Matlab routine to determine the half-life of the radioactive element and compare it against the expected/theoretical value
2 Comments
What exactly is the goal? You do seem to be generating an exponential decay curve. What would be the point of calculating lambda when you already knew tau to start with? Are you supposed to be pretending that the generated N represents measured data with an unknown time constant?
For finding the time constant, are you intended to use standard Matlab tools, or are you supposed to somehow rewrite the above code to do the task?
Rookiee
on 3 Apr 2021
Accepted Answer
More Answers (0)
Categories
Find more on Fit Postprocessing 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!