How to plot a biexponential fit?

조회 수: 11 (최근 30일)
Goncalo Costa
Goncalo Costa 2022년 3월 24일
댓글: Goncalo Costa 2022년 3월 24일
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에서 Stress and Strain에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by