![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
matlab
跳坑坑
这个作者很懒,什么都没留下…
展开
-
matlab不动点迭代代码
%不动点迭代 function [xc,k] = fpi(g,x0,tol,N) x1=g(x0); k=1; while abs(x1-x0) > tol x0 =x1; x1=g(x0); if k==N fprintf('Fixed-point iteration failed!') break end k=k+1; end xc = x1;原创 2021-10-04 22:12:03 · 5451 阅读 · 0 评论 -
matlab二分法求方程的根(数值分析)
代码 function xc = bisect(f,a,b,tol) % bisect 二分法求解 %f: a if sign(f(a))*sign(f(b))>=0 error('f(a)f(b)<0 not satisfied!') % 停止运行 end fa = f(a); fb = f(b); while (b-a)/2 > tol c = (a+b)/2; fc = f(c); if fc == 0 break end原创 2021-09-24 12:42:55 · 10692 阅读 · 4 评论