| 查看: 2520 | 回复: 19 | |||
[交流]
【求助】feval的使用
|
|
现在在看《数值分析导论》韩渭敏译,379页中的边值问题, 在对这个偏微分方程的求解过程中用到一条语句 feval(f,(1:n-1)*h,(1:n-1)*h) 注释中说明f方程的右边的函数值,我不知道如何写这个f的m函数,有人可以指点一下啊 |
» 猜你喜欢
跳槽后在研项目怎么办?
已经有9人回复
什么时候开奖?
已经有9人回复
2026国自然函评费到账
已经有16人回复
售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急
已经有9人回复
让我中一个面上吧!
已经有14人回复
今天放榜吗?
已经有16人回复
售SCI一区T0P文章,我:8.O.55.1.O54,科目全,可伽急
已经有5人回复
售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急
已经有10人回复
售SCI一区T0P文章,我:8.O.55.1.O54,科目全,可伽急
已经有5人回复
售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急
已经有4人回复
» 抢金币啦!回帖就可以得到:
告别流水线爽文!108万字完结仙侠《女娲石之灵石奇缘(仙界篇)》值得细品
+1/9020
基金祈福
+1/986
散金币
+1/943
散金祈福
+3/795
每年这时候我都再仔细读一遍《范进中举》
+1/473
南方医科大学|生物材料与医学工程团队诚聘科研助理
+2/258
散金求好运
+1/191
诚征另一半
+1/172
坐标北京诚征男友
+1/112
美国University of Texas at Arlington土木结构工程方向2027年春季全奖博士招生
+1/97
上海交通大学张航课题组招聘博士后(电化学储能)
+1/89
山东征女友,坐标济南
+1/89
上海交通大学张航课题组招聘博士后(电化学能量存储与转换)
+1/43
瑞典-博后-固态电池-粘结剂-锂离子电池方向
+1/36
流放岭南浮肿了求救
+1/20
2027环境工程博士申请
+1/8
南方医科大学深圳医院陈烨/余涛教授课题组联合培养博士后招聘
+1/6
CS phd 寻找机会
+1/5
【产品测评分享】体外转录产量不理想、dsRNA 副产物高?T7 RNA 聚合酶实测体验
+1/1
2026年国自然
+1/1
2楼2011-01-07 20:04:38
3楼2011-01-07 21:47:10
4楼2011-01-08 10:12:37
5楼2011-01-08 10:28:14
|
>> Poisson('f','g',16,1e-8,10000) Warning: Could not find an exact (case-sensitive) match for 'Poisson'. C:\Documents and Settings\lenovo\My Documents\MATLAB\poisson.m is a case-insensitive match and will be used instead. You can improve the performance of your code by using exact name matches and we therefore recommend that you update your usage accordingly. Alternatively, you can disable this warning using warning('off','MATLAB:dispatcher:InexactCaseMatch'). This warning will become an error in future releases. ??? Error using ==> mtimes Inner matrix dimensions must agree. Error in ==> f at 2 f=-2*pi^2*sin(pi*x)*sin(pi*y); Error in ==> poisson at 13 Fr(2:n,2:n)=h^2*feval(f,(1:n-1)*h,(1:n-1)*h); 错误的提示 |
6楼2011-01-08 10:51:59
7楼2011-01-08 10:57:32
8楼2011-01-08 11:04:41
|
function U=poisson(f,g,n,tol,max_it) if nargin<5 max_it=10000 end if nargin<4 tol=1e-5 end n1=n+1; h=1/n; toln=(h^2)*tol; Fr=zeros(n,n); Fr(2:n,2:n)=h^2*feval(f,(1:n-1)*h,(1:n-1)*h); U=zeros(n1,n1); U(1,1:n1)=feval(g,0,(0:n)*h); U(n1,1:n1)=feval(g,1,(0:n)*h); U(1:n1,1)=feval(g,(0:n)*h,0); U(1:n1,n1)=feval(g,(0:n)*h,1); rel_err=1; itnum=0; while((rel_err>toln)&(itnum<=max_it)) err=0; umax=0; for j=2:n for i=2:n temp=(U(i+1,j)+U(i-1,j)+U(i,j+1)+U(i,j-1))/4-Fr(i,j); dif=abs(temp-u(i,j)); if(err<=diff) err=dif; end U(i,j)=temp; temp=abs(temp); if(umax<=temp) umax=temp; end end end itnum=itnum+1; rel_err=err/umax; end %X=(0:h,:n*h)'; %Y=X; %surf(X,Y,U') %xlabel('x-axis') %ylabel('y-axis') %zlabel('the numerical solution') %title('Plot of the mumerical solution') X=(0:h:n*h)';Y=X; subplot(1,2,1) surf(X,Y,U') xlabel('x-axis') ylabel('y-axis') zlabel('The numerical solution') s1=springtf('h=6.4f',h) title(s1) hold on Err=sin(pi*X)*sin(pi*Y')-U; subplot(1,2,2) surf(X,Y,Err') |
9楼2011-01-08 11:05:13
10楼2011-01-08 11:06:14
11楼2011-01-08 11:06:47
12楼2011-01-08 11:09:33
13楼2011-01-08 11:34:09
14楼2011-01-08 11:48:22
15楼2011-01-08 11:53:22
16楼2011-01-08 12:03:07
17楼2011-01-08 13:37:10
18楼2011-01-08 14:13:18
19楼2011-01-08 14:32:43
20楼2011-01-08 15:21:26









回复此楼