% clear all
  close all

a=1;
b=0;



h=0.01;

%choose size of the domain in x direction
x=0:h:a;
% choose size of the domain in y direction
y=0:h:a;

% number of the points in x direction

nx= length(x);

% number of the points in y direction

ny= length(y);

[X,Y] = meshgrid(x,y);

%eigenvectors in 1D case for poisson equation -laplace u=f

for k=1:nx
	z(k) =sqrt(2/(nx+1))*sin((3*k*pi)/(nx+1));


end

plot(z);


B=[];
B(nx,ny) = 0;

%compute eigenvectors for 2D case for -laplace u=f

 for count =1:4

 if(count==1)
% eigenvector (1,1)
k=1; l=1;
 elseif (count==2)
% eigenvector (2,1)
k=2; l=1;
 elseif (count==3)
% eigenvector (1,2)
k=1; l=2;
 elseif (count==4)
% eigenvector (3,2)
k=3; l=2;
end

for j=1:ny
	for i=1:nx
		x=(i-1)*h;
y= (j-1)*h;

% compute eigenvectors 
	%	B(i,j) = sin(((a-b)*i*pi)/(nx+1))*sin((a-b)*j*pi/(ny+1));

% alternative way how to compute eigenvectors

zk= (sin(k*(a-b)*pi*x));
zl=(sin(l*(a-b)*pi*y));



%B(i,j) = (sin(k*(a-b)*pi*x))*(sin(l*(a-b)*pi*y));
B(i,j) = (sin(zk))*(sin(zl));

A(i,j) =zk*zl';

end
end

str_xlabel = ['Eigenvector V=','z' num2str(k),' z',  num2str(l), '^T'];

subplot (2,2,count)

%contour(X,Y,B,12,'LineWidth',1);

%surf(B);
%figure

contourf(X,Y,B,12);


title(str_xlabel)

 end
