poisson1D(f,Uleft,Uright,N,L)
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
Platform Compatibility
Windows macOS LinuxCategories
- Mathematics and Optimization > Partial Differential Equation Toolbox > Domain-Specific Modeling > Electromagnetics >
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 |