フィルターのクリア

How to use a user defined function inside the curve fitting function?

4 ビュー (過去 30 日間)
Victor Carneiro da Cunha Martorelli
Victor Carneiro da Cunha Martorelli 2023 年 12 月 20 日
編集済み: Torsten 2023 年 12 月 21 日
Hi all,
I have a funciton that takes into account various parameters:
function [concatz] = my_fit_functioncpe(freq,parameters)
Rsolc = parameters(1);
Cm = parameters(2);
Rq = parameters(3);
Rn = parameters(4);
Ln = parameters(5);
RKch = parameters(6);
Rm = parameters(7);
Lm = parameters(8);
Rl = parameters(9);
Rctc = parameters(10);
T = parameters(11);
qc = parameters(12);
w = 2 * pi * freq;
Z = Rctc + 1./((1./Rsolc+T*(1j*w).^qc)) + 1./((1j*w*Cm)+ 1/Rl + 1/Rq + 1/RKch + 1./(Rn + (1j*w*Ln)) + 1./(Rm + (1j*w*Lm)));%4c
%CPEIMPEDANCE = 1./(T*(1j*w).^qc);
%Z = 1./(1./(Rctc)+(1./(Rsolc+CPEIMPEDANCE))) + 1./((1j*w*Cm) +1./Rl+ 1./Rq + 1./RKch + 1./(Rn + (1j*w*Ln)) + 1./(Rm + (1j*w*Lm)));
reZ = real(Z);
imZ = imag(Z);
concatz = cat(2,reZ,imZ);
end
But I want it to take this initial values like a normal function and fit it to my data. I am not sure how to do that and I have searched everywhere. In python, curve_fit seems to do the trick but I need it for matlab.

回答 (1 件)

Torsten
Torsten 2023 年 12 月 21 日
編集済み: Torsten 2023 年 12 月 21 日
Use "lsqcurvefit".
There are lots of examples under
that show how to use a function to define the response values from a model equation.
But your model is hopelessly overfitted. Reduce the number of parameters first.
As an example, for the expression 1./Rl+ 1./Rq + 1./RKch, the three parameters cannot be fitted independently. Substitute them by one parameter 1/R. Other cases where reductions are necessary are obvious.

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by