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

matlab例程

开发平台:

Matlab

  1. %func7p2.m计算机辅助求解
  2. %(1)
  3. s=-2;f=-3;tol=0.01;
  4. difference=1
  5. while(abs(difference)>tol)
  6.     if(sub7p2((s+f)/2)>0)
  7.         f=(s+f)/2;
  8.     else
  9.         s=(s+f)/2;
  10.     end
  11.     difference=sub7p2((s+f)/2);
  12. end
  13. disp(difference);disp(s/2+f/2)
  14. %(2)
  15. x=linspace(-6,-0.2,100);y=linspace(-6,-0.2,100);yy=linspace(-6,-0.2,100);xx=linspace(-6,-0.2,100)
  16. for k=1:100
  17.     yy(k)=1/y(k);xx(k)=sin(x(k))
  18.     %plot(xx(k),x(k),'o',yy(k),y(k),'.-')
  19. end
  20. plot(x,xx,'-',y,yy,'-')
  21. disp(s/2+f/2)
  22. %从图中易看出其解区间,以二分法算得解为:1.1094,2.7813,6.4375,9.3125,如解区间出错,则无法算得结果
  23. %作图[-6,0.2]有解区间[-2,-3],解为-1.1094,[-3,-2],解为-2.7813