%牛顿迭代法
p0=1.5;
i=1;
while i==1
p=p0-fun(p0)/fun2(p0);
if abs(p-p0)<0.00001
disp(p);
break;
else
p0=p;
end
end
function y=fun(x)
y=3^(3*x+1)-7.5^(2*x);
end
function y=fun2(x)
y=diff(fun(x));
end
...全文
702打赏收藏
牛顿迭代法MATLAB想问一下哪里出错了然后怎么改:错误使用 /
矩阵维度必须一致。
%牛顿迭代法 p0=1.5; i=1; while i==1 p=p0-fun(p0)/fun2(p0); if abs(p-p0)<0.00001 disp(p); break; else p0=p; end end function y=fun(x) y=3^(3*x+1)-7.5^(2*x); end function y=fun2(x) y=diff(fun(x)); end