| 20 | 1/1 | 返回列表 |
| 查看: 2198 | 回復(fù): 19 | |||
[交流]
【求助】feval的使用
|
|
現(xiàn)在在看《數(shù)值分析導(dǎo)論》韓渭敏譯,379頁中的邊值問題, 在對這個偏微分方程的求解過程中用到一條語句 feval(f,(1:n-1)*h,(1:n-1)*h) 注釋中說明f方程的右邊的函數(shù)值,我不知道如何寫這個f的m函數(shù),有人可以指點一下啊 |
» 搶金幣啦!回帖就可以得到:
+1/635
+1/99
+1/86
+1/83
+1/82
+1/82
+1/66
+1/57
+1/46
+1/44
+3/43
+1/42
+1/40
+2/38
+1/38
+2/34
+2/34
+1/9
+1/7
+1/1
版主 (職業(yè)作家)
版主 (職業(yè)作家)
|
>> 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); 錯誤的提示 |
版主 (職業(yè)作家)
|
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') |
版主 (職業(yè)作家)
版主 (職業(yè)作家)
版主 (職業(yè)作家)
版主 (職業(yè)作家)
| 20 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 323求調(diào)劑 +6 | 洼小桶 2026-03-18 | 6/300 |
|
|---|---|---|---|---|
|
[考研] 求調(diào)劑一志愿海大,0703化學學碩304分,有大創(chuàng)項目,四級已過 +6 | 幸運哩哩 2026-03-22 | 10/500 |
|
|
[考研] 260求調(diào)劑 +3 | 朱芷琳 2026-03-20 | 4/200 |
|
|
[考研] 求調(diào)劑 +5 | Zhangbod 2026-03-21 | 7/350 |
|
|
[考研]
|
酥酥魚.. 2026-03-21 | 3/150 |
|
|
[考研] 286求調(diào)劑 +10 | Faune 2026-03-21 | 10/500 |
|
|
[考研] 一志愿南大,0703化學,分數(shù)336,求調(diào)劑 +3 | 收到VS 2026-03-21 | 3/150 |
|
|
[考研] 求調(diào)劑 +3 | .m.. 2026-03-21 | 4/200 |
|
|
[基金申請]
學校已經(jīng)提交到NSFC,還能修改嗎?
40+4
|
babangida 2026-03-19 | 9/450 |
|
|
[考研] 求調(diào)劑 +3 | 白QF 2026-03-21 | 3/150 |
|
|
[考研] 一志愿山大07化學 332分 四六級已過 本科山東雙非 求調(diào)劑! +3 | 不想理你 2026-03-16 | 3/150 |
|
|
[考研] 機械專碩299求調(diào)劑至材料 +3 | kkcoco25 2026-03-16 | 4/200 |
|
|
[考研] 265求調(diào)劑 +3 | Jack?k?y 2026-03-17 | 3/150 |
|
|
[考研] 083200學碩321分一志愿暨南大學求調(diào)劑 +3 | innocenceF 2026-03-17 | 3/150 |
|
|
[考研] 265求調(diào)劑 +9 | 梁梁校校 2026-03-17 | 9/450 |
|
|
[考研]
|
.6lL 2026-03-18 | 8/400 |
|
|
[考研] 330求調(diào)劑 +4 | 小材化本科 2026-03-18 | 4/200 |
|
|
[考研] 350求調(diào)劑 +5 | weudhdk 2026-03-19 | 5/250 |
|
|
[考研] 081700化工學碩調(diào)劑 +3 | 【1】 2026-03-16 | 3/150 |
|
|
[碩博家園] 湖北工業(yè)大學 生命科學與健康學院-課題組招收2026級食品/生物方向碩士 +3 | 1喜春8 2026-03-17 | 5/250 |
|