how can i solve these errors in matlab code?

1 view (last 30 days)
Hi all,
when I use the function "nlinfit" to find the parameters of a second order system, these errors are appeared:
??? Error using ==> nlinfit>checkFunVals at 357 MODELFUN has returned Inf or NaN values.
Error in ==> nlinfit>LMfit at 304 if funValCheck && ~isfinite(sse), checkFunVals(r); end
Error in ==> nlinfit at 167 [beta,J,lsiter,cause] = LMfit(X,y, model,beta,options,verbose,maxiter);
...................................... the Matlab code is: -------------------------------------- function mdl =MyModelisation(x,y)
model=@(p,t) p(1).*(1-exp(-p(2).*p(3).*t).*sin(p(3)*sqrt(1-p(2)^p(2)).*t./sqrt(1-p(2)^2)+asin(sqrt(1-p(2)^2))));
beta= EstimG(y); mdl=nlinfit(x,y,model,beta);
thank you in advence
end
function g= EstimG(x)
n = find(diff(diff(x) > 0) < 0); u = find(x(n+1) > x(n)); n(u) = n(u)+1; moy=0; pic=n(3) for i=pic:length(x) moy=moy+x(i); end moy=moy/(length(x)-n(3)+1);
delta=u(2)-u(1); delta=delta/10; % en seconde zeta=0.3; wd=2*pi/delta; wn=wd/sqrt(1-zeta^2); g=[moy, zeta, wn] end ----------------------------------
how cqan I solve this errors?
thank you

Answers (0)

Categories

Find more on Signal Generation and Preprocessing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!