2.2.3.9.48 matrixbase::MeshGrid


Description

Get 2-D grid matrices based on the coordinates contained in vectors vX and vY. mX is a matrix where each row is a copy of vX, and mY is a matrix where each column is a copy of vY. Both mX and mY have vX.GetSize() rows and vY.GetSize() columns.

Syntax

BOOL MeshGrid(const vector & vX, const vector & vY, matrix & mX, matrix & mY)

Parameters

vX
[input] Including the coordinates to be repeatedly copied into mX.
vY
[input] Including the coordinates to be repeatedly copied into mY.
mX
[output] Matixbase derived object containing the row-wise copies of vX.
mY
[output] Matixbase derived object containing the column-wise copies of vY.

Return

Return TRUE on successful exit and FALSE on failure.

Examples

EX1

void matrixbase_MeshGrid_ex1()
{
	vector vX = {1,2,3};
	vector vY = {4,5};
	matrix mX, mY;
	int ii, jj;
	bool bVectorCheck = MeshGrid(vX, vY, mX, mY);
	
	// print the meshgrids matrices mX and mY
	if (bVectorCheck)
	{
		printf("mX = \n");
		for(ii=0; ii<mX.GetNumRows(); ii++)
		{
			for(jj=0; jj<mX.GetNumCols(); jj++)
			{
				printf("%f ",mX[ii][jj]);
			}
			printf("\n");
		}	
		
		printf("mY = \n");
		for(ii=0; ii<mY.GetNumRows(); ii++)
		{
			for(jj=0; jj<mY.GetNumCols(); jj++)
			{
				printf("%f ",mY[ii][jj]);
			}
			printf("\n");
		}
	}	
}

Remark

See Also

matrixbase::GetSubMatrix

Header to Include