• <noscript id="ecgc0"><kbd id="ecgc0"></kbd></noscript>
    <menu id="ecgc0"></menu>
  • <tt id="ecgc0"></tt>

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

    這個例子展示了如何在L形區域上計算和表示有限差分拉普拉斯算子。

    東西/原料

    • matlab軟件
    • 電腦

    方式/步調

    1. 1

      對于這個示例,NUMGRID數字點在L形域內。SPY函數是一個很是有效的東西,它可以直不雅地顯示給定矩陣中非零元素的模式。

      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. 2

      按“Enter”鍵。

      得圖1、圖2所示。

    3. 3

      離散拉普拉斯式

      操縱DELSQ生當作離散的拉普拉斯函數。SPY函數給出了矩陣總體的圖形感受。

      D = delsq(G);

      spy(D)

      title('The 5-point Laplacian')

      % Number of interior points

      N = sum(G(:)>0)

    4. 4

      按“Enter”鍵。

      得圖3所示。

    5. 5

      Dirichlet邊值問題

      最后,我們解決了稀少線性系統的Dirichlet邊值問題。問題如下:

      delsq(u) = 1 in the interior,

        u = 0 on the boundary.

    6. 6

      rhs = 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

      end

    7. 7

      解決方案

      將解決方案映射到網格中,并將其顯示為等高線圖。

      U = G;

      U(G>0) = full(u(G(G>0)));

      clabel(contour(U));

      prism

      axis square ij

    8. 8

      按“Enter”鍵。

      得如圖4所示。

    9. 9

      此刻顯示作為網格圖的解決方案。

      colormap((cool+1)/2);

      mesh(U)

      axis([0 n 0 n 0 max(max(U))])

      axis square ij

    10. 10

      按“Enter”鍵。

      得如圖5所示。

    原作者:matlab教程舉報
    • 發表于 2020-02-12 20:00
    • 閱讀 ( 1139 )
    • 分類:其他類型

    你可能感興趣的文章

    相關問題

    0 條評論

    請先 登錄 后評論
    聯系我們:uytrv@hotmail.com 問答工具
  • <noscript id="ecgc0"><kbd id="ecgc0"></kbd></noscript>
    <menu id="ecgc0"></menu>
  • <tt id="ecgc0"></tt>
    久久久久精品国产麻豆