matlab怎么利用有限差分拉普拉斯算子

這個例子展示了如何在L形區域上計算和表示有限差分拉普拉斯算子 。
需要這些哦
matlab軟件
電腦
方式/
1域
對于這個示例 , NUMGRID數字點在L形域內 。 SPY函數是一個很是有效的東西 , 它可以直不雅地顯示給定矩陣中非零元素的模式 。
【matlab怎么利用有限差分拉普拉斯算子】R = 'L'; % Other possible shapes include S,N,C,D,A,H,B
% Generate and display the grid.
n = 32;
G = numgrid(R,n);
spy(G)
title('A finite difference grid')
% Show a smaller version as sample.
g = numgrid(R,12)

2按“Enter”鍵 。
得圖1、圖2所示 。

matlab怎么利用有限差分拉普拉斯算子



matlab怎么利用有限差分拉普拉斯算子



3離散拉普拉斯式
操縱DELSQ生當作離散的拉普拉斯函數 。 SPY函數給出了矩陣總體的圖形感受 。
D = delsq(G);
spy(D)
title('The 5-point Laplacian')
% Number of interior points
N = sum(G(:)>0)

4按“Enter”鍵 。
得圖3所示 。
matlab怎么利用有限差分拉普拉斯算子



5Dirichlet邊值問題
最后 , 我們解決了稀少線性系統的Dirichlet邊值問題 。 問題如下:
delsq(u) = 1 in the interior,
  u = 0 on the boundary.

6rhs = ones(N,1);
if (R == 'N') % For nested dissection, turn off minimum degree ordering.
   spparms('autommd',0)
   u = D\rhs;
   spparms('autommd',1)
else
   u = D\rhs; % This is used for R=='L' as in this example


7解決方案

將解決方案映射到網格中 , 并將其顯示為等高線圖 。
U = G;
U(G>0) = full(u(G(G>0)));
clabel(contour(U));
prism
axis square ij

8按“Enter”鍵 。
得如圖4所示 。
matlab怎么利用有限差分拉普拉斯算子



9此刻顯示作為網格圖的解決方案 。
colormap((cool+1)/2);
mesh(U)
axis([0 n 0 n 0 max(max(U))])
axis square ij

10按“Enter”鍵 。
得如圖5所示 。
matlab怎么利用有限差分拉普拉斯算子



原作者:matlab教程舉報
以上內容就是matlab怎么利用有限差分拉普拉斯算子的內容啦 , 希望對你有所幫助哦!

    猜你喜歡