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
Best Answer