%% Two-Dimensional Laplace Problem
% unit square, Dirichlet boundary conditions

% n * n interior grid points
n=20;  

% matrix and right-hand side of the finite-difference discretization
A = (gallery('poisson',n));
b = zeros(n*n,1);
b(1:n:n^2) = 100; % here are boundary values

% solve linear system of equatins
u = A\b;

% map the solution vector to the 2D-grid matrix
U = zeros(n);
U(:) = u;
U = U';

% grid matrix plus boundary rows and columns
U0 = zeros(n+2);
U0(:,1) = 100;
U0(2:n+1,2:n+1) = U;

% graphics output
figure(1)
imagesc(U0)

figure(2)
surf(U0)
