0
에 인수로 함수를 전달하는 내가 가지고 m-파일에 정의 된이 기능 : 나는 이러한 명령으로 호출하려고하면 다음어떻게 matlab에
function[it,xvect,xdif,fx]=bisez(a,b,nmax,toll,fun)
it=-1;
xvect=[];
xdif=[];
fx=[];
err=toll+1;
while(it<nmax && err>toll)
x=(b+a)/2;
if(fun(x)==0)
err=0;
else
err=abs(b-a)/2;
end
it=it+1;
xvect=[xvect;x];
xdif=[xdif;err];
fx=[fx:fun(x)];
if(fun(x)*fun(a)>0)
a=x;
else
b=x;
end;
end;
if(it<nmax)
fprintf('Convergence computed at step k:%d\n',it);
else
fprinf('Iteration limit reached: %d\n',it);
end
fprintf('Computed root: %-12.8f\n',xvect(it+1));
return
:
[email protected](x)exp(x);
a=1;
b=1.5;
nmax=1000;
toll=2;
bisez(a,b,nmax,toll,fun)
내가 얻을 이 오류 :
??? Undefined function or method 'bisez' for input arguments of type 'function_handle'.
무엇이 누락 되었습니까?
PS : 나는 Matlab 2007b
본부를, 당신이 바로, 당신을 감사합니다! – Aslan986