Undefined function 'diff' for input arguments of type 'function_handle'.
이전 댓글 표시
Dear All,
would you like please to help me about this error "Undefined function 'diff' for input arguments of type 'function_handle'."? Thanks in advance
This is the following code:
xguess = 2400; % initial guess
emax = 1e-7; % Maximum error
imax = 1000; % maximum number of iterations
maxstep = 3002; % maximum x-step size
minslope = .01; % minimum value for the slope (prevents divide by zero)
F1=@(x) 2400 + (1- (sqrt(pi)*erf(x))./exp(-x.^2)/2)./diff((sqrt(pi)*erf(x)./exp(-x.^2)/2));
lim = @(x,xlim) max(-xlim,min(xlim,x)); % limiter function
i=1;
x=xguess;
while (i<imax) && (abs(600))>=emax % needs abs(deltax) (can be + or -)
yguess = F1(x); % Get the function value for the x guess
slope = diff(F1,x); % Get the function slope for x-guess
if(abs(slope)<minslope) % Don't allow slope to go to zero (trap divide by zero condition)
slope = minslope*sign(slope);
end
yerr = yguess; % Since the desired value is zero, the function value represents the error value
deltax = -yerr/slope; % calculate the x-step
xstep = lim(deltax,maxstep); % limit the x-step (deltax) to +/- maxstep
x = x + xstep; % apply the (limited) x-step to the x-guess value and repeat the iteration
i=i+1; % update the increment counter
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!