How can i fit the data to the custom equation without using Curve fitting Toolbox ?

24 次查看(过去 30 天)
I have a data for voltage(V) with respect to time(t). I want to fit the curve with equation without using the curve fiting tool box,
V(t)=A+B*(1-exp(-t/C))+D*(1-exp(-t/E)),
where the parameters to be estimated are A, B, C, D, E
So please help me with the problem....
please go through the attached document for V-t data...
  1 个评论
Rik
Rik 2019-9-6
Your question is not urgent. That being said, you can define a cost function and use fminsearch to find the values of the parameters. Note that fminsearch is sensitive to initial estimate errors.

请先登录,再进行评论。

采纳的回答

Matt J
Matt J 2019-9-6
编辑:Matt J 2019-9-6
FMINSPLEAS will work well for this problem. It uses fminsearch, but in a savvy way that reduces the problem to only 2 unknowns. It can be downloaded from here,
For you, its application would look like,
flist={1,@(x,t) 1-exp(-t/x(1)) , @(x,t) 1-exp(-t/sum(x)) };
[x,y]=fminspleas(flist,[C0,C0+E0],tdata,Vdata,[0,0]); %C0 and E0 are initial guesses of C and E
A=y(1);
B=y(2);
C=x(1);
D=y(3);
E=x(2)-C;

更多回答(2 个)

Walter Roberson
Walter Roberson 2019-9-6
You can fit any equation by calculating
SSE = @(Current_Parameters) sum( (Predicted_Value(Input_Independent_Variable, Current_Parameters) - Actual_Values).^2 );
and minimizing SSE .
Here, Predicted_Value would be your model function that takes your input independent variable and the current guesses at model parameters, and predicts the outputs for those parameters at the values of the independent variable. The current parameters will be input as a vector, so like
@(t,ABCDE) ABCDE(1) + ABCDE(2) .* (1-exp(-t./ABCDE(3))) + ABCDE(4) .* (1-exp(-t./ABCDE(5)))

Rik
Rik 2019-9-6
Sligthly exanpding on what Walter suggests:
fun=@(ABCDE,t) ABCDE(1) + ABCDE(2) .* (1-exp(-t./ABCDE(3))) + ABCDE(4) .* (1-exp(-t./ABCDE(5)));
initial_guess=[1 1 1 1 1];%enter appropriate initial estimate
ABCDE=fit_fminsearch(f,x,y,initial_guess)
I attached my fit_fminsearch function. I don't feel it is quite ready for the FEX, but it will probably end up there is due time. This function doesn't require any toolbox and should work on all releases of both Matlab and GNU Octave. It uses fminsearch, so it is still sensitive to initial estimates being close to a local minimum or being too far off.

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by