How to plot a biexponential fit?

14 次查看(过去 30 天)
I have got some data array (P2P) and a time array (t_array) plotted under this simple line of code:
plot(t_array, P2P, 'o')
This works perfectly, but now I want to fit a biexponential fit line through this data, and I don't know how to do so.
I have read the instructions given in this link, but it still doesn't make sense to me. I attempted replicating what was written in the link, as follows:
P2P0=P2P(1); %setting my La0 as the first element in my y-axis data array
ft = fittype(sprintf('%e+A1*(1-exp(-gamma1*t))+A2*(1-exp(-gamma2*t))',P2P0),...
'independent','t','dependent', 'P2P' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.Lower = [0 0 0 0];%lower bounds (A1, gamma1, A2, gamma2)
opts.StartPoint = [1 1 1 1];
[fitresult, gof] = fit( t_array, P2P, ft, opts ); %substituted La by P2P and t by t_array
plot(fitresult,t_array,P2P, 'o')
I merely substituted the La data by my P2P data, and time by t_array, but this gives me a horizontal fit line that doesn't match the data which exponentialy decreases (similarly, but not quite, to the data shown in this other link).
Could it be that I must change my lowed bounds (pots.Lower) and my start point (opts.StartPoint)?
I don't understand the meaning of these arrays? Why are there 4 elements in these arrays? What can I do to fit an array through my data?
  3 个评论
Goncalo Costa
Goncalo Costa 2022-3-24
This has now been added. The data wasn't mine and I was hesitatant in sharing until I had permission. Thank you for your help.
Goncalo Costa
Goncalo Costa 2022-3-24
An answer to this question had already been given at the following link: https://uk.mathworks.com/matlabcentral/answers/122561-help-with-a-fit
I believe this fits what I need .

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by