%
%  w04volcano.m -- djm -- 26 january 2008
%

%  parameters
Lx = 1;  Ly = 1;  Nx = 64; Ny = 64;

%  vectors of plot points (x,y)
dx = 2*Lx/Nx;  x = -Lx + (0:Nx)*dx;
dy = 2*Ly/Ny;  y = -Ly + (0:Ny)*dy;

%  matrices of plot points (xg,yg)
%  type "help meshgrid" in matlab
[xg,yg] = meshgrid(x,y);

%
%  this script uses ELEMENTWISE arithmetic:  .* & .^
%
%  volcano function
volc = (xg.^2 + yg.^2).*(xg.^2 - Lx^2).*(yg.^2 - Ly^2);

figure(1);  clf
surf(x,y,volc);  colorbar
title(['\bf surface plot of f(x,y)'],'fontsize',14)
xlabel('\bf x-axis','fontsize',12)
ylabel('\bf y-axis','fontsize',12)
zlabel('\bf f(x,y)-axis','fontsize',12)

%  type "help contour" in matlab:  
%  - the vector specifies the contour levels
%
figure(2);  clf
contour(x,y,volc,[0:0.03:0.3]);  colorbar
title(['\bf contour plot of f(x,y)'],'fontsize',14)
xlabel('\bf x-axis','fontsize',12)
ylabel('\bf y-axis','fontsize',12)

% % % % % % 
%
%  make this section into a (double) summation loop
%
Fser = zeros(size(xg));

jx = 2;  ky = 3;
c_jk = 1;
Fser = Fser + c_jk * cos((jx*pi/Lx)*xg).*cos((ky*pi/Ly)*yg);
%
%
%  don't forget to change the title of the plot
%
% % % % % % 

figure(3);  clf
surf(x,y,Fser);  colorbar
title(['\bf surface plot of a fourier term:  u_j(x) v_k(y)'],'fontsize',14)
xlabel('\bf x-axis','fontsize',12)
ylabel('\bf y-axis','fontsize',12)
zlabel('\bf u_j(x) v_k(y)-axis','fontsize',12)

%
%  make a contour plot of the error
%