Force a starting point on exponential graph
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I'm trying to fit an exponential curve to a process describing a radioactive decay. This is my data:
counts=[2423970,2171372,2065862,1830553,1100899,1037972,914015,752138,684123,606126];
normalized_counts=counts./counts(1);
time=[24.4,40.1,49.2,69.9,137.1,144.4,160.6,185.4,192.7,209.7];
At first I tried using the loveable cftool, which easily managed to fit a "classic" exponential function: y=a*exp(b*x). However, I'm interested in fitting a "pure" exponential [normalized_counts=exp(-a*time)]. When I tried to insert this custom function, I got this error:
Inf computed by model function, fitting cannot continue.
Try using or tightening upper and lower bounds on coefficients.
Then I tried to force an initial condition, so that the exponent will have to pass through the point (24.4, 1) using the code below, but to no avail as well:
x0=24.4;
y0=1;
g = @(p,time)y0*exp(-p*(time-x0));
f = fit(time,normalized_counts,g)
plot(f,time,normalized_counts)
[I got some matrix size errors, tried to add ' (to transpose) to the arrays but that didn't help as well].
Would apprecaite your help!
0 comentarios
Respuestas (2)
Davide Masiello
el 24 de Sept. de 2022
Editada: Davide Masiello
el 25 de Sept. de 2022
See if this can help
counts = [2423970,2171372,2065862,1830553,1100899,1037972,914015,752138,684123,606126];
normalized_counts = counts./counts(1);
time = [24.4,40.1,49.2,69.9,137.1,144.4,160.6,185.4,192.7,209.7];
p0 = 1e-3;
g = @(p,x) exp(-p*(x-time(1)));
f = fit(time',normalized_counts',g,'StartPoint',p0)
plot(f,time,normalized_counts)
7 comentarios
Davide Masiello
el 27 de Sept. de 2022
My pleasure, if that's the answer you were looking for don't forget to accept it!
Torsten
el 25 de Sept. de 2022
Editada: Torsten
el 25 de Sept. de 2022
You must normalize to time = 0, not time = 24.4.
The initial mass is the key, not the mass when already 24.4 (whatever) have passed.
I think what you should try to do is to introduce another unknown "counts_initial" and fit the curve as
counts_normalized = exp(-p(1)*time)
with
time=[24.4,40.1,49.2,69.9,137.1,144.4,160.6,185.4,192.7,209.7];
counts_normalized = counts/counts_initial
This means that the curve you have to fit is
counts/counts_initial = exp(-p(1)*time)
thus again the general exponential
counts = counts_initial*exp(-p(1)*time)
counts = [2423970,2171372,2065862,1830553,1100899,1037972,914015,752138,684123,606126];
time = [24.4,40.1,49.2,69.9,137.1,144.4,160.6,185.4,192.7,209.7];
p0 = [3e6,1e-3];
g = @(p,x) p(1)*exp(-p(2)*x);
g1 = @(p,x) g(p,x)-counts;
p = lsqnonlin(@(p)g1(p,time),p0);
hold on
plot(time,counts,'o')
plot([0,time],g(p,[0,time]))
hold off
grid
0 comentarios
Ver también
Categorías
Más información sobre Interpolation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!