del2_5pt.m
来自「matlab 源代码,五点差分格式,可以直接运行,用于其他方面」· M 代码 · 共 30 行
M
30 行
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.
%x方向和z方向的空间采样率必须一致
% 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
% for first dimension
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
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 + =
减小字号Ctrl + -
显示快捷键?