Custim fit doesn't work when adding problem values

3 ビュー (過去 30 日間)
Lars Duelund
Lars Duelund 2016 年 3 月 1 日
コメント済み: Julian Groß-Funk 2021 年 9 月 16 日
Dear All
I am trying to fit some experimental data to a custom fit by using the fit function from the Curve Fitting Toolbox. In my fit I have 3 'problem' parameter (i.e a value i don't fit) which changes for each data point. But when I include them in fit function I get the error:
Error using fittype/testCustomModelEvaluation (line 12) Expression testMem(x,DH,K, Cdi,Vcell,dCl0i) is not a valid MATLAB expression, has non-scalar coefficients, or cannot be evaluated: Error in fittype expression ==> testMem(x,DH,K, Cdi,Vcell,dCl0i) ??? Index exceeds matrix dimensions.
My fit function is:
function y=testMem(x,DH,K, Cdi,Vcell,dCl0i)
y=zeros(size(x));
for i=1:length(x)
y(i)=dCl0i(i)*Vcell(i).*Cdi(1).*DH.*(K./((1+K.*x(i)).^2));
end
end
And I do the fit by the following:
ftype=fittype('testMem(x,DH,K, Cdi,Vcell,dCl0i)','problem', {'Cdi','Vcell','dCl0i'})
f=fit(ClipCelli,data(:,1)*1e-6,ftype,'problem', {Cdert0i,Vtoti,dClipCelli})
All the data and all the 'problem' numbers are 25 x 1 vectors of the type double. And the function IS working if i try ti with reasonable value for my two fit parameters (DH, K)
If I remove all the problem values from my fit is works (in the sense that I don't get any error messages, the fit is totally off).
Any ideas for what is going on here? Any hints what i should check? ALL help is highly appropriated
  1 件のコメント
Julian Groß-Funk
Julian Groß-Funk 2021 年 9 月 16 日
Problem variables are only allowed to be one character long. That means only a-z and A-Z are available as problem variables

サインインしてコメントする。

回答 (0 件)

カテゴリ

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