Nlinfit error with func2str
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Michael Lherbette
el 11 de Ag. de 2015
Comentada: Michael Lherbette
el 12 de Ag. de 2015
Hello,
I am trying to fit a curve using this function: t is the time vector, x the force measurement, d0 and nu are constants. I want to extract Er, tau1 and tau2.
function [Er,tau1,tau2] = viscoelasticcone(t,x,d0,nu)
fitfunctionconical=sprintf('Er*2*tan(35*pi/180)/(pi*(1-%d^2))*%d^2*(1+(tau1-tau2)/tau2*exp(-t/tau2))',nu,d0);
ftconical=fittype( fitfunctionconical, 'independent', 't', 'dependent', 'F');
[fitresult,R,~,CovB,MSE] = nlinfit(t,x, ftconical,[1e3 0.001 0.001]);
fit=ftconical(fitresult,t);
[Ypred,delta] = nlpredci(ftconical,t,fitresult,R,'Covar',CovB,'MSE',MSE,'SimOpt','on');
confidence{k}=delta;
lower = Ypred - delta;
upper = Ypred + delta;
end
If I use this function however, i get the following error:
Undefined function 'func2str' for input arguments of type 'fittype'.
Error in nlinfit (line 204)
m = message('stats:nlinfit:ModelFunctionError',func2str(model));
Any help ?
Michael
0 comentarios
Respuesta aceptada
Walter Roberson
el 11 de Ag. de 2015
You need to call fit() on fit objects returned from fittype(), not nlinfit()
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Linear and Nonlinear Regression en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!