필터 지우기
필터 지우기

Force a starting point on exponential graph

조회 수: 6 (최근 30일)
Ran Kagan
Ran Kagan 2022년 9월 24일
댓글: Davide Masiello 2022년 9월 27일
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!

답변 (2개)

Davide Masiello
Davide Masiello 2022년 9월 24일
편집: Davide Masiello 2022년 9월 25일
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)
f =
General model: f(x) = exp(-p*(x-time(1))) Coefficients (with 95% confidence bounds): p = 0.007151 (0.006894, 0.007408)
plot(f,time,normalized_counts)
  댓글 수: 7
Ran Kagan
Ran Kagan 2022년 9월 27일
Davide Masiello
Davide Masiello 2022년 9월 27일
My pleasure, if that's the answer you were looking for don't forget to accept it!

댓글을 달려면 로그인하십시오.


Torsten
Torsten 2022년 9월 25일
편집: Torsten 2022년 9월 25일
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);
Local minimum possible. lsqnonlin stopped because the size of the current step is less than the value of the step size tolerance.
hold on
plot(time,counts,'o')
plot([0,time],g(p,[0,time]))
hold off
grid

카테고리

Help CenterFile Exchange에서 Fit Postprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by