%% 3-D Grid
% Create 3-D grid coordinates from x-, y-, and z-coordinates defined in the interval [0,6], and evaluate the expression x^2 + y^2 + z^2.

x = 0:2:6;
y = 0:1:6;
z = 0:3:6;
[X,Y,Z] = meshgrid(x,y,z);
F = X.^2 + Y.^2 + Z.^2;

%
% Determine the size of the grid. The three coordinate vectors have different lengths, forming a rectangular box of grid points.

gridsize = size(F)

%
% Use the single-input syntax to generate a uniformly spaced 3-D grid based on the coordinates defined in x. The new grid forms a cube of grid points.

[X,Y,Z] = meshgrid(x);
G = X.^2 + Y.^2 + Z.^2;
gridsize = size(G)

% Copyright 2012 The MathWorks, Inc.