How to plot a biexponential fit?
조회 수: 5 (최근 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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!