function U=lapsolve1(bot,right,top,left)
% Solve Laplace equation on a square.
% Parameters:
%
%    bot,right,top,left are vectors of boundary values,
%    each has length n=nr. of inner nodes/axis
% The solution is returned as an (n+2)x(n+2) matrix (the boundary
% values are appended)
n=length(bot);  % nr. of interior nodes
m=n+1;          % nr. of subintervals
% Assemly of A, use function lapm that has been written earlier.
%A=lapm(m);       % Make sure to include this within Matlab path
A=feval('lapm',m) % Lievää mystiikkaa, mutta jos polkuja järjestelee
                  % "väärässä järjestyksessä", tulee virhe ja feval-vihje.
% Assembly of RHS
B=[bot;[left(2:n-1)' zeros(n-2,n-2) right(2:n-1)'];top];
B(1,1)=bot(1)+left(1);B(1,n)=bot(n)+right(1);
B(n,1)=left(n)+top(1);B(n,n)=top(n)+right(n);
B=B';B=B(:);
% Now the system is ready, then just solve it.
uvek=A\B;
U=reshape(uvek,n,n)';
U=flipud(U);
% Append boundary values.

U=[fliplr(left)' U fliplr(right)'];

NW=0.5*(left(n)+top(1));NE=0.5*(top(n)+right(n));
SE=0.5*(bot(n)+right(1));SW=0.5*(bot(1)+left(1));

U=[NW top NE;
   U;
   SW bot SE];

% Remember to check everything went all right by
% del2
