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

matlab例程

开发平台:

Matlab

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