Four-parameters optimization of a 1D function: wrong values

Hello everybody,
I have some data (see file data.txt) that I have to fit with a function equal to:
function = p1*e^(-p2*ln((t-p4)/p3)^2)+p5, with t>p4
t is the time (hours), p are the 5 parameters to be optimized.
t is expressed in hours, so I defined it as t=((0:1:length(data(:,1))-1)/60)'.
The optimizaiton should be based on the minimization of the square error between data and the fit. I defined the error as:
error_function = @(params) sum((fun(params, t) - funzy).^2), where funzy is the vector with values coming from data-txt divided per 10.
I tried using fminsearch, however, the fourth parameter p4 results being negative and this does not have a physical meaning. Expected values of the parameters should be p1 = max value of the data function, p2 = curvature of the fit (0.5 to 5), p3 = time at which the ppeak occurs (starting from d), p4 = time at which values in data are not zero ( to 2), and p5 = offset y-axis (around -0.002).
I tired fmincon but it seemed not working and after that I tried even to use the genetic algorithm, but without any satisfactory results.
Can someone please help me?
Thanks a lot!

2 件のコメント

Matt J
Matt J 2024 年 2 月 23 日
編集済み: Matt J 2024 年 2 月 23 日
Your data.txt has 5 columns. We don't know what they mean.
Maja
Maja 2024 年 2 月 24 日
You are right, sorry. I am using the third colum!

サインインしてコメントする。

 採用された回答

Matt J
Matt J 2024 年 2 月 23 日
編集済み: Matt J 2024 年 2 月 23 日

0 投票

I would recommend using fminspleas,
with INLP=[p2,p3,p4] and ILP=[p1,p5]. You can also impose a positivity bound on p4 with INLB=[-inf,-inf,0].

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeOptimization Toolbox についてさらに検索

製品

リリース

R2023b

質問済み:

2024 年 2 月 23 日

コメント済み:

2024 年 2 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by