Difference between revisions of "Fdmat.m"
(Created page with "Returns arbitrary-order central finite-difference differentiation matrix (sparse) with unit spacing and sided finite-difference schemes of the same order at the edges. Syntax:...") |
|||
| Line 1: | Line 1: | ||
| − | Returns arbitrary-order central finite-difference differentiation | + | {{DISPLAYTITLE:fdmat.m}} |
| + | Returns arbitrary-order central finite-difference differentiation matrices (sparse) with unit grid point spacing. | ||
| − | + | ==Syntax== | |
| − | + | D=fdmat(dim,nstenc,order,boundary) | |
| + | |||
| + | ==Arguments== | ||
dim - dimension of the column vector to be | dim - dimension of the column vector to be | ||
differentiated | differentiated | ||
| − | + | nstenc - number of points in the finite diffe- | |
rence stencil | rence stencil | ||
| Line 16: | Line 19: | ||
finite difference schemes, 'pbc' | finite difference schemes, 'pbc' | ||
assumes periodic boundaries. The | assumes periodic boundaries. The | ||
| − | default is ' | + | default is 'pbc'. |
| + | |||
| + | ==Outputs== | ||
| + | |||
| + | D - finite difference differentiation matrix | ||
| + | |||
| + | ==Examples== | ||
| + | A three-point second derivative matrix with periodic boundary conditions is: | ||
| + | |||
| + | >> full(fdmat(10,3,2,'pbc')) | ||
| + | |||
| + | ans = | ||
| + | |||
| + | -2 1 0 0 0 0 0 0 0 1 | ||
| + | 1 -2 1 0 0 0 0 0 0 0 | ||
| + | 0 1 -2 1 0 0 0 0 0 0 | ||
| + | 0 0 1 -2 1 0 0 0 0 0 | ||
| + | 0 0 0 1 -2 1 0 0 0 0 | ||
| + | 0 0 0 0 1 -2 1 0 0 0 | ||
| + | 0 0 0 0 0 1 -2 1 0 0 | ||
| + | 0 0 0 0 0 0 1 -2 1 0 | ||
| + | 0 0 0 0 0 0 0 1 -2 1 | ||
| + | 1 0 0 0 0 0 0 0 1 -2 | ||
| + | |||
| + | ==See also== | ||
| + | [[fdvec.m]], [[fdlap.m]], [[fdhess.m]], [[fdkup.m]], [[fdweights.m]], [[fftdiff.m]], [[fourdif.m]] | ||
| + | |||
| + | |||
| + | ''Version 2.2, authors: [[Ilya Kuprov]]'' | ||
Revision as of 14:47, 16 August 2018
Returns arbitrary-order central finite-difference differentiation matrices (sparse) with unit grid point spacing.
Contents
Syntax
D=fdmat(dim,nstenc,order,boundary)
Arguments
dim - dimension of the column vector to be
differentiated
nstenc - number of points in the finite diffe-
rence stencil
order - order of the derivative required
boundary - 'wall' fills the edges with sided
finite difference schemes, 'pbc'
assumes periodic boundaries. The
default is 'pbc'.
Outputs
D - finite difference differentiation matrix
Examples
A three-point second derivative matrix with periodic boundary conditions is:
>> full(fdmat(10,3,2,'pbc')) ans =
-2 1 0 0 0 0 0 0 0 1
1 -2 1 0 0 0 0 0 0 0
0 1 -2 1 0 0 0 0 0 0
0 0 1 -2 1 0 0 0 0 0
0 0 0 1 -2 1 0 0 0 0
0 0 0 0 1 -2 1 0 0 0
0 0 0 0 0 1 -2 1 0 0
0 0 0 0 0 0 1 -2 1 0
0 0 0 0 0 0 0 1 -2 1
1 0 0 0 0 0 0 0 1 -2
See also
fdvec.m, fdlap.m, fdhess.m, fdkup.m, fdweights.m, fftdiff.m, fourdif.m
Version 2.2, authors: Ilya Kuprov