How to plot a biexponential fit?

5 Ansichten (letzte 30 Tage)
Goncalo Costa
Goncalo Costa am 24 Mär. 2022
Kommentiert: Goncalo Costa am 24 Mär. 2022
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 Kommentare
Goncalo Costa
Goncalo Costa am 24 Mär. 2022
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 am 24 Mär. 2022
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 .

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Linear and Nonlinear Regression finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by