poisson1D(f,Uleft,U​right,N,L)

Solves 1D poisson equation, with dirichlet boundary conditions using SINE transform
162 Downloads
Updated 23 Feb 2015

View License

function out = poisson1D(f,Uleft,Uright,N,L)
% POISSON1D solves the poisson equation d2U/dX2 = F.
% u = poisson1D(f,Uleft,Uright,N,L)
%
% f: a vector representing the right-hand-side
% Uleft: dirichlet boundary condition at u(0)
% Uright: dirichlet boundary condition at u(L)
% N: Number of nodes
% L: Length of domain
dx = L / (N - 1);
uB = zeros(length(f),1);
uB(2) = Uleft;
uB(end-1) = Uright;
f = f * dx^2 - uB;
b = dst(f);
m = (1:length(b))';
a = b ./ (2 * ( cos(m * pi / (N - 1)) - 1 ));
uSOL = idst(a);
uSOL(1) = Uleft;
uSOL(end) = Uright;
out = uSOL;
end

Cite As

Koorosh Gobal (2024). poisson1D(f,Uleft,Uright,N,L) (https://www.mathworks.com/matlabcentral/fileexchange/49801-poisson1d-f-uleft-uright-n-l), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0