Fitting Model : This expression has no coefficients or non-scalar coefficients

조회 수: 34 (최근 30일)
Hi,
Im trying to fit a model i've made to some experimental data, however I'm getting an error i don't seem to understand.
I followed the fittype guide.
Heres my code:
%This is the model
function pdf = pdf_GG(Var)
I=0.3;
LKK = sqrt(Var);
alpha = (exp((5.19.*LKK.^2)./((1 + 9.01.*LKK.^(12/5)).^(7/6))) -1).^-1;
beta = (exp((6.22.*LKK.^2)./((1 + 22.39.*LKK.^(12/5)).^(5/6))) -1).^-1;
k = (alpha+beta)./2;
k1 = alpha.*beta;
H =4.*(k1.^k)./(gamma(alpha).*gamma(beta));
H1 = I.^(k-1);
D = 6.*sqrt(k1.*I);
pdf = H.*H1.*besselk((alpha-beta),D);
And now my main code:
%Fitting
x0=[0.2];
fitfun=fittype(@(Var) pdf_GG( Var),'independent','Var');% this is where i get the this expression has no coeffiecients or non-scalar coefficients error
[fitted_curve,gof]=fit(ctrs',pn',fitfun,'StartPoint',x0);
Any help on how i should proceed to make this fit?Thank you very much
  댓글 수: 3
LB
LB 2020년 11월 3일
@Sindar I tried but that just replies with an error: "Custom equations must produce an output vector, matrix or array that is the same size and shape as the input data.This custom equation fails to meet that requirement" How can i fix this?The equation is suposed to return PDF values
Sindar
Sindar 2020년 11월 4일
Does this return a 2-element array? (and do you expect it to?)
pdf_GG([0 1])
If not, add a breakpoint at the last line and check the sizes of all the intermediate variables

댓글을 달려면 로그인하십시오.

채택된 답변

Juhi Singh
Juhi Singh 2020년 11월 5일
The error is being encountered because pdf_GG() returns a vector. Unfortunately, specifying the coefficients as vector is not supported. There is no workaround.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Fit Postprocessing에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by