Frequently we will get a function f(x,y) that we will need to plot. The naive way will be to generate an array for x and y and then iterate through all combinations and then use the plot3 function. Here is a sample:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Assume function f(x,y)=-(x^2-2)^2 - (x^2-exp(y))^2% Crude Methodx = -5:.1:5;y = 1:.1:4;points=[];i=1;for xp = xfor yp= yf = -(xp^2-2)^2 - (xp^2-exp(yp))^2;points(i,1) = xp;points(i,2) = yp;points(i,3) = f;i=i+1;endendfigure;hold on;grid on;xlabel('x');ylabel('y');zlabel('f');plot3(points(:,1),points(:,2),points(:,3),'.');hold off;- Download this code: plot3d.m
But this code is inefficient. Looping is to be avoided in MATLAB because operations on matrices are faster. Moreover, the plot3 function does not give shading. We get the following as the output:

Avoiding loops, we can implement the above code in a different way. We avoid loops and use the surf command.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Assume function f(x,y)=-(x^2-2)^2 - (x^2-exp(y))^2% Better Methodx = -5:.2:5;y = 1:.2:4;x_2d = ones(length(y),length(x))*diag(x);y_2d = diag(y)*ones(length(y),length(x));func = -(x_2d.^2-2).^2 - (x_2d.^2-exp(y_2d)).^2;figure;hold on;grid on;xlabel('x');ylabel('y');zlabel('f');surf(x,y,func);hold off;- Download this code: surf.m
We get the following output

The trick in the above code involves creating the x_2d and y_2d array.


but may have a more complicated large scale structure. The surface of Earth is a simple example: At small distances it looks like the Euclidean
but from far away it is
, the two dimensional surface of a sphere. The behaviour at the small scale and large scale can be totally different. For instance, in 



Date on a magazine…what does it mean?
After a little thought I came to the conclusion that the dates on the magazine should be designed to make the job simple for the magazine seller. Magazines can be quarterly, monthly, fortnightly or weekly. Also, each shops sells at least 50 different kinds of magazines. So the shop seller will find it tedious to calculate the date at which each magazine should be taken off the shelf. There is a simpler solution: the magazine publisher prints the date at which it expires!
Therefore it seems obvious that the date on the magazine is an expiry date and not an issue date.