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 CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by