% -----------------------------------------------------
% plotting3d_mesh.m
% -----------------------------------------------------
% Write a program that computes and plots given function
% as a 3D mesh or surface plot
% -----------------------------------------------------
% Notes: None. 
% -----------------------------------------------------
% Copyright and license details available at matlabmarina.com
%------------------------------------------------------

clear; 
clc;
close all;

% define the coordinates along x and y
x = -3 : 1 : 3;
y = -3 : 1 : 2;

% define the coordinates along the x-y plane
[xx, yy] = meshgrid(x,y);
disp(xx);
disp(yy);

% define and compute the given function along the x-y coordinates
zz = xx .^2 - yy .^2;

% plot the function as a 3D mesh or surface
figure(1)
mesh(xx, yy, zz);      % change to surf to see the difference
title('function z=x^2-y^2');
xlabel('elements in x');
ylabel('elements in y');
zlabel('elements in z');
axis tight;
shading interp;
