⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 del2_5pt.m

📁 有限差分中用于五点差分的matlab程序
💻 M
字号:
function [output]=del2_5pt(input,delx)
% DEL2_5PT ... compute the 5 point Laplacian
%
% [output]=del2_5pt(input,delx)
%
% DEL2_5PT computes the 5 point approximation to the laplacian operator of 
% the two dimensional matrix 'input'.  The horizontal and vertical bin
% spacing of the matrix MUST be the same.    
%
% input = input matrix
% delx = the horizontal/ vertical bin spacing in consistent units
%
% output = the output matrix



[nrows,ncolumns]=size(input);

input2=zeros(nrows+2,ncolumns+2);     %对应二阶精度的有限差分,矩阵取法
input2(2:nrows+1,2:ncolumns+1)=input;
factor=1/(delx^2);
clear input   %删除input矩阵


% for first dimension  -----可以看成对x的二阶偏导数

   output = (input2(3:nrows+2,2:ncolumns+1) - 2.*input2(2:nrows+1,2:ncolumns+1) +...
                  input2(1:nrows,2:ncolumns+1))*factor;

% for second dimension ------可以看成对z的二阶偏导数

 output = (input2(2:nrows+1,3:ncolumns+2) - 2.*input2(2:nrows+1,2:ncolumns+1) +...
                 input2(2:nrows+1,1:ncolumns))*factor+ output;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -