Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
初级会员
注册日期: 2009-02-06
年龄: 38
帖子: 1
声望力: 0 ![]() |
![]()
我初用matlab,最近在看《数值方法(matlab版)》,开篇第一个用MATLAB采用迭代法求固定总是足不出来,很打击我的积极性。下面我把我做得过程写出来,请高手批评指正。
1.第一个m.file function [k,p,err,P]=fixpt(g,p0,tol,max1) p(1)=p0 for k-2:max1 p(k)=feval(g,p(k-1)); err=abs(p(k)-p(k-1)); relerr=err/(abs(p(k))+eps); p=p(k); if(err<tol) | (relerr<tol),break;end end if k==max1 disp('maximum number of iterations exceeded') end p=p'; 2.第二个m.file function y=g(x) y=2*(x-1).^0.5; 3.然后在command window里 [k,p,err,P]=fixpt(g,2.1,0.00001,10000) 我不知道哪里做得不对,很着急,请指教,谢谢! |
![]() |
![]() |
|
|
![]() |
||||
主题 | 主题作者 | 版面 | 回复 | 最后发表 |
[资料]BP网络总结及应用实例 | guofeng0108 | MATLAB论坛 | 37 | 2012-06-11 22:08 |
[求助]我是初学者,想学习图像变换 | cjlong | MATLAB论坛 | 0 | 2009-02-15 16:57 |
有哪位做过BEESSEL法数字下变频? | yqgame365 | MATLAB论坛 | 0 | 2008-12-07 23:53 |
[求助]如何用FFT从数据序列中提取相位信息? | leechau | Origin论坛 | 0 | 2008-11-05 21:50 |
Simplify Instrument Communication: Using Instrument Drivers with the Instrument Contr | TechnicalArticles | MATLAB技术文章 | 0 | 2008-01-06 16:32 |