func7p1.m
上传用户:zhdd911129
上传日期:2007-05-11
资源大小:722k
文件大小:1k
源码类别:

matlab例程

开发平台:

Matlab

  1. %func7p1.m二分法解方程
  2. %(1)
  3. s=1;f=3;tol=0.01;i=0
  4. difference=1
  5. while(abs(difference)>tol)
  6.     if(sub7p11((s+f)/2)>0)
  7.         f=(s+f)/2;
  8.     else
  9.         s=(s+f)/2;
  10.     end
  11.     difference=sub7p11((s+f)/2);
  12.     i=i+1
  13. end
  14. %用四次循环得到解 1.9375,误差0.004
  15. %(2)
  16. s=0;f=1.5;tol=0.01;i=0
  17. difference=1
  18. while(abs(difference)>tol)
  19.     if(sub7p12((s+f)/2)>0)
  20.         f=(s+f)/2;
  21.     else
  22.         s=(s+f)/2;
  23.     end
  24.     difference=sub7p12((s+f)/2);
  25.     i=i+1
  26. end
  27. %  用6次循环得到解 1.1133,误差0.0012