func7p2.m
资源名称:数值分析课程设计.zip [点击查看]
上传用户:zhdd911129
上传日期:2007-05-11
资源大小:722k
文件大小:1k
源码类别:
matlab例程
开发平台:
Matlab
- %func7p2.m计算机辅助求解
- %(1)
- s=-2;f=-3;tol=0.01;
- difference=1
- while(abs(difference)>tol)
- if(sub7p2((s+f)/2)>0)
- f=(s+f)/2;
- else
- s=(s+f)/2;
- end
- difference=sub7p2((s+f)/2);
- end
- disp(difference);disp(s/2+f/2)
- %(2)
- x=linspace(-6,-0.2,100);y=linspace(-6,-0.2,100);yy=linspace(-6,-0.2,100);xx=linspace(-6,-0.2,100)
- for k=1:100
- yy(k)=1/y(k);xx(k)=sin(x(k))
- %plot(xx(k),x(k),'o',yy(k),y(k),'.-')
- end
- plot(x,xx,'-',y,yy,'-')
- disp(s/2+f/2)
- %从图中易看出其解区间,以二分法算得解为:1.1094,2.7813,6.4375,9.3125,如解区间出错,则无法算得结果
- %作图[-6,0.2]有解区间[-2,-3],解为-1.1094,[-3,-2],解为-2.7813