How to plot a biexponential fit?
3 views (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on Linear and Nonlinear Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!