Using the C Math Library | ![]() ![]() |
Determining Array Type
The MATLAB C Math Library includes several routines that allow you to determine the type of an array. Each routine tests for a particular type of array and returns 1 if the array being tested matches the indicated type and 0 (zero) otherwise.
As an example, the following code uses the mlfIsnumeric()
routine to test if a 2-by-2 array of ones is a numeric array.
mxArray *A = NULL; mxArray *B = NULL; /* Create two-dimensional array */ mlfAssign(&A, mlfOnes(mlfScalar(2),mlfScalar(2),NULL)); /* Determine if array is numeric */ mlfAssign(&B, mlfIsnumeric(A)); mlfFprintf(mlfScalar(1), /* stdout */ mxCreateString("Isnumeric returns %d.\n"), B, /* array */ NULL); mxDestroyArray(A); mxDestroyArray(B);
Because the array created is numeric, this code produces the following output:
Isnumeric returns 1.
![]() | Displaying MATLAB Arrays | Determining Array Size | ![]() |