meshgridCreating grid points for 3D surface plot
[X,Y] = meshgrid(x)[X,Y] = meshgrid(x, y)x and y should be numeric vectors. If any of x and y is non-vector, it will be first reshaped to a vector.X and Y, which can be used to evaluate a bivariate function, or used as grid points for surface plot.X and Y have the same sizes.X and Y are empty, if either x or y is empty.[X,Y,Z] = meshgrid(x)[X,Y,Z] = meshgrid(x, y, z)x, y and z should be vectors. If either x, y or z is non-vector, it will be first reshaped to a vector.X, Y and Z, which can be used to evaluate a function of 3 variables.X, Y and Z have the same sizes.X, Y and Z are empty, if either x, y or z is empty.ndgrid in which the vertical direction is the [X,Y] = meshgrid(1:5)
X =
1.0000 2.0000 3.0000 4.0000 5.0000
1.0000 2.0000 3.0000 4.0000 5.0000
1.0000 2.0000 3.0000 4.0000 5.0000
1.0000 2.0000 3.0000 4.0000 5.0000
1.0000 2.0000 3.0000 4.0000 5.0000
Y =
1.0000 1.0000 1.0000 1.0000 1.0000
2.0000 2.0000 2.0000 2.0000 2.0000
3.0000 3.0000 3.0000 3.0000 3.0000
4.0000 4.0000 4.0000 4.0000 4.0000
5.0000 5.0000 5.0000 5.0000 5.0000
x = 0:2:6;
y = 0:1:6;
z = 0:3:6;
[X,Y,Z] = meshgrid(x,y,z)
X(:, :, 1) =
0.0000 2.0000 4.0000 6.0000
0.0000 2.0000 4.0000 6.0000
0.0000 2.0000 4.0000 6.0000
0.0000 2.0000 4.0000 6.0000
0.0000 2.0000 4.0000 6.0000
0.0000 2.0000 4.0000 6.0000
0.0000 2.0000 4.0000 6.0000
X(:, :, 2) =
0.0000 2.0000 4.0000 6.0000
0.0000 2.0000 4.0000 6.0000
0.0000 2.0000 4.0000 6.0000
0.0000 2.0000 4.0000 6.0000
0.0000 2.0000 4.0000 6.0000
0.0000 2.0000 4.0000 6.0000
0.0000 2.0000 4.0000 6.0000
X(:, :, 3) =
0.0000 2.0000 4.0000 6.0000
0.0000 2.0000 4.0000 6.0000
0.0000 2.0000 4.0000 6.0000
0.0000 2.0000 4.0000 6.0000
0.0000 2.0000 4.0000 6.0000
0.0000 2.0000 4.0000 6.0000
0.0000 2.0000 4.0000 6.0000
Y(:, :, 1) =
0.0000 0.0000 0.0000 0.0000
1.0000 1.0000 1.0000 1.0000
2.0000 2.0000 2.0000 2.0000
3.0000 3.0000 3.0000 3.0000
4.0000 4.0000 4.0000 4.0000
5.0000 5.0000 5.0000 5.0000
6.0000 6.0000 6.0000 6.0000
Y(:, :, 2) =
0.0000 0.0000 0.0000 0.0000
1.0000 1.0000 1.0000 1.0000
2.0000 2.0000 2.0000 2.0000
3.0000 3.0000 3.0000 3.0000
4.0000 4.0000 4.0000 4.0000
5.0000 5.0000 5.0000 5.0000
6.0000 6.0000 6.0000 6.0000
Y(:, :, 3) =
0.0000 0.0000 0.0000 0.0000
1.0000 1.0000 1.0000 1.0000
2.0000 2.0000 2.0000 2.0000
3.0000 3.0000 3.0000 3.0000
4.0000 4.0000 4.0000 4.0000
5.0000 5.0000 5.0000 5.0000
6.0000 6.0000 6.0000 6.0000
Z(:, :, 1) =
0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000
Z(:, :, 2) =
3.0000 3.0000 3.0000 3.0000
3.0000 3.0000 3.0000 3.0000
3.0000 3.0000 3.0000 3.0000
3.0000 3.0000 3.0000 3.0000
3.0000 3.0000 3.0000 3.0000
3.0000 3.0000 3.0000 3.0000
3.0000 3.0000 3.0000 3.0000
Z(:, :, 3) =
6.0000 6.0000 6.0000 6.0000
6.0000 6.0000 6.0000 6.0000
6.0000 6.0000 6.0000 6.0000
6.0000 6.0000 6.0000 6.0000
6.0000 6.0000 6.0000 6.0000
6.0000 6.0000 6.0000 6.0000
6.0000 6.0000 6.0000 6.0000