matlab编了个函数死活说语句无效,debug无能求大神指点,function bisect_sub(f,a,b,eps,N)u=zeros(1,N); v=zeros(1,N);k=1;p=a+(b-a)/2;q=a;while abs(p-q)0)a=p;f1=fp;q=p;u(k)=p;v(k)=fp;p=a+(b-a)/2;elseif(f2*fp>0)b=p;f2=fp;q=p;u(k)=p;v(k)=fp;
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/26 10:03:23
matlab编了个函数死活说语句无效,debug无能求大神指点,function bisect_sub(f,a,b,eps,N)u=zeros(1,N); v=zeros(1,N);k=1;p=a+(b-a)/2;q=a;while abs(p-q)0)a=p;f1=fp;q=p;u(k)=p;v(k)=fp;p=a+(b-a)/2;elseif(f2*fp>0)b=p;f2=fp;q=p;u(k)=p;v(k)=fp;
matlab编了个函数死活说语句无效,debug无能求大神指点,
function bisect_sub(f,a,b,eps,N)
u=zeros(1,N);
v=zeros(1,N);
k=1;
p=a+(b-a)/2;
q=a;
while abs(p-q)0)
a=p;
f1=fp;
q=p;
u(k)=p;v(k)=fp;
p=a+(b-a)/2;
elseif(f2*fp>0)
b=p;
f2=fp;
q=p;
u(k)=p;v(k)=fp;
p=a+(b-a)/2;
end
fprintf('k=%d,x(%d)=%14.12e,y(%d)=%18.12e\n',k,k,u(k),k,v(k))
k=k+1;
end
end
matlab编了个函数死活说语句无效,debug无能求大神指点,function bisect_sub(f,a,b,eps,N)u=zeros(1,N); v=zeros(1,N);k=1;p=a+(b-a)/2;q=a;while abs(p-q)0)a=p;f1=fp;q=p;u(k)=p;v(k)=fp;p=a+(b-a)/2;elseif(f2*fp>0)b=p;f2=fp;q=p;u(k)=p;v(k)=fp;
subs作用是对变量进行替换,f的表达式是什么,这里并没有定义,然后subs(f,x,a)说明f中包含x吗?