Main Content

이 번역 페이지는 최신 내용을 담고 있지 않습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.

C Matrix API

MATLAB® mxArray 데이터 구조와 호환되는 C/C++ 프로그램 작성

MATLAB R2017b 이하 버전에서 작동하는 C 프로그램을 작성하려면 C Matrix API의 함수를 사용하십시오. 이러한 함수는 mxArray 데이터 구조와 호환되는 C MEX 함수 또는 C 엔진 응용 프로그램을 작성하는 데 사용됩니다.

참고

MathWorks는 가능하면 C 응용 프로그램보다 C++ 응용 프로그램을 선택하도록 권장합니다. MATLAB에서 직접 C++ 라이브러리 기능을 호출하는 방법에 대한 자세한 내용은 C++에서 MATLAB 호출하기 또는 MATLAB에서 C++ 라이브러리 항목을 참조하십시오.

C Matrix API는 두 가지 버전이 있습니다.

  • MATLAB R2018a에는 실수부/허수부 결합형 복소수 API에 C Matrix API 기능이 포함되어 있습니다. 자세한 내용은 MATLAB Support for Interleaved Complex API in MEX Functions 항목을 참조하십시오.

  • MATLAB R2017b에는 실수부/허수부 분리형 복소수 API에 C Matrix API 기능이 포함되어 있습니다.

이러한 라이브러리 함수를 사용하는 예제를 보려면 다음 항목을 참조하십시오.

주의

C Matrix API는 최신 C++ 기능을 지원하는 MATLAB Data API와 호환되지 않습니다. C Matrix API의 함수는 C++ MEX 응용 프로그램 또는 C++용 MATLAB Engine API의 함수와 함께 사용할 수 없습니다.

C 데이터형

mxArrayC type for MATLAB array
mwSizeC type for mxArray size values
mwIndexC type for mxArray index values
mwSignedIndexSigned integer C type for mxArray size values
mxCharType for string array
mxLogicalType for logical array
mxComplexityFlag specifying whether array has imaginary components

mxArray 특성

mxIsNumericDetermine whether mxArray is numeric
mxIsComplexDetermine whether data is complex
mxGetNumberOfDimensionsNumber of dimensions in mxArray
mxGetElementSizeNumber of bytes required to store each data element
mxGetDimensionsPointer to dimensions array
mxSetDimensionsModify number of dimensions and size of each dimension
mxGetNumberOfElementsNumber of elements in numeric mxArray
mxCalcSingleSubscriptOffset from first element to desired element
mxGetMNumber of rows in mxArray
mxSetMSet number of rows in mxArray
mxGetNNumber of columns in mxArray
mxSetNSet number of columns in mxArray
mxIsEmptyDetermine whether mxArray is empty
mxIsFromGlobalWSDetermine whether mxArray was copied from MATLAB global workspace

데이터형 만들기, 쿼리 및 액세스하기

모두 확장

mxCreateDoubleMatrix2-D, double-precision, floating-point array
mxCreateDoubleScalarScalar, double-precision array initialized to specified value
mxCreateNumericMatrix2-D numeric matrix
mxCreateNumericArrayN-D numeric array
mxCreateUninitNumericMatrixUninitialized 2-D numeric matrix
mxCreateUninitNumericArrayUninitialized N-D numeric array
mxIsScalarDetermine whether array is scalar array
mxGetScalarReal component of first data element in array
mxIsDoubleDetermine whether mxArray represents data as double-precision, floating-point numbers
mxGetDoublesReal data elements in mxDOUBLE_CLASS array
mxSetDoublesSet real data elements in mxDOUBLE_CLASS array
mxIsSingleDetermine whether mxArray represents data as single-precision, floating-point numbers
mxGetSinglesReal data elements in mxSINGLE_CLASS array
mxSetSinglesSet real data elements in mxSINGLE_CLASS array
mxGetPr(Not recommended) Real data elements in mxDOUBLE_CLASS array
mxSetPr(Not recommended) Set real data elements in mxDOUBLE_CLASS array
mxIsInt8Determine whether mxArray represents data as signed 8-bit integers
mxGetInt8sReal data elements in mxINT8_CLASS array
mxSetInt8sSet real data elements in mxINT8_CLASS array
mxIsUint8Determine whether mxArray represents data as unsigned 8-bit integers
mxGetUint8sReal data elements in mxUINT8_CLASS array
mxSetUint8sSet real data elements in mxUINT8_CLASS array
mxIsInt16Determine whether mxArray represents data as signed 16-bit integers
mxGetInt16sReal data elements in mxINT16_CLASS array
mxSetInt16sSet real data elements in mxINT16_CLASS array
mxIsUint16Determine whether mxArray represents data as unsigned 16-bit integers
mxGetUint16sReal data elements in mxUINT16_CLASS array
mxSetUint16sSet real data elements in mxUINT16_CLASS array
mxIsInt32Determine whether mxArray represents data as signed 32-bit integers
mxGetInt32sReal data elements in mxINT32_CLASS array
mxSetInt32sSet real data elements in mxINT32_CLASS array
mxIsUint32Determine whether mxArray represents data as unsigned 32-bit integers
mxGetUint32sReal data elements in mxUINT32_CLASS array
mxSetUint32sSet real data elements in mxUINT32_CLASS array
mxIsInt64Determine whether mxArray represents data as signed 64-bit integers
mxGetInt64sReal data elements in mxINT64_CLASS array
mxSetInt64sSet data elements in mxINT64_CLASS array
mxIsUint64Determine whether mxArray represents data as unsigned 64-bit integers
mxGetUint64sReal data elements in mxUINT64_CLASS array
mxSetUint64sSet real data elements in mxUINT64_CLASS array
mxGetComplexDoublesComplex data elements in mxDOUBLE_CLASS array
mxSetComplexDoublesSet complex data elements in mxDOUBLE_CLASS array
mxGetComplexSinglesComplex data elements in mxSINGLE_CLASS array
mxSetComplexSinglesSet complex data elements in mxSINGLE_CLASS array
mxGetImagDataImaginary data elements in numeric mxArray
mxSetImagDataSet imaginary data elements in numeric mxArray
mxGetPi(Not recommended) Imaginary data elements in mxDOUBLE_CLASS array
mxSetPi(Not recommended) Set imaginary data elements in mxDOUBLE_CLASS array
mxGetComplexInt8sComplex data elements in mxINT8_CLASS array
mxSetComplexInt8sSet complex data elements in mxINT8_CLASS array
mxGetComplexUint8sComplex data elements in mxUINT8_CLASS array
mxSetComplexUint8sSet complex data elements in mxUINT8_CLASS array
mxGetComplexInt16sComplex data elements in mxINT16_CLASS array
mxSetComplexInt16sSet complex data elements in mxINT16_CLASS array
mxGetComplexUint16sComplex data elements in mxUINT16_CLASS array
mxSetComplexUint16sSet complex data elements in mxUINT16_CLASS array
mxGetComplexInt32sComplex data elements in mxINT32_CLASS array
mxSetComplexInt32sSet complex data elements in mxINT32_CLASS array
mxGetComplexUint32sComplex data elements in mxUINT32_CLASS array
mxSetComplexUint32sSet complex data elements in mxUINT32_CLASS array
mxGetComplexInt64sComplex data elements in mxINT64_CLASS array
mxSetComplexInt64sSet complex data elements in mxINT64_CLASS array
mxGetComplexUint64sComplex data elements in mxUINT64_CLASS array
mxSetComplexUint64sSet complex data elements in mxUINT64_CLASS array
mxGetPi(Not recommended) Imaginary data elements in mxDOUBLE_CLASS array
mxSetPi(Not recommended) Set imaginary data elements in mxDOUBLE_CLASS array
mxCreateSparse2-D sparse array
mxCreateSparseLogicalMatrix2-D, sparse, logical array
mxIsSparseDetermine whether input is sparse mxArray
mxGetNzmaxNumber of elements in IR, PR, and PI arrays
mxSetNzmaxSet storage space for nonzero elements
mxGetIrSparse matrix IR array
mxSetIrIR array of sparse array
mxGetJcSparse matrix JC array
mxSetJcJC array of sparse array
mxGetDataData elements in nonnumeric mxArray
mxSetDataSet pointer to data elements in nonnumeric mxArray
mxCreateString1-N array initialized to specified string
mxCreateCharMatrixFromStrings2-D mxChar array initialized to specified value
mxCreateCharArrayN-D mxChar array
mxIsCharDetermine whether input is mxChar array
mxGetCharsPointer to character array data
mxIsLogicalDetermine whether mxArray is of type mxLogical
mxIsLogicalScalarDetermine whether scalar array is of type mxLogical
mxIsLogicalScalarTrueDetermine whether scalar array of type mxLogical is true
mxClassIDEnumerated value identifying class of array
mxCreateLogicalArrayN-D logical array
mxCreateLogicalMatrix2-D logical array
mxCreateLogicalScalarScalar, logical array
mxGetLogicalsPointer to logical array data
mxIsClassDetermine whether mxArray is object of specified class
mxGetClassIDClass of mxArray
mxGetClassNameClass of mxArray as string
mxSetClassNameStructure array to MATLAB object array
mxGetPropertyValue of public property of MATLAB object
mxSetPropertySet value of public property of MATLAB object
mxCreateStructMatrix2-D structure array
mxCreateStructArrayN-D structure array
mxIsStructDetermine whether mxArray is structure
mxGetFieldPointer to field value from structure array, given index and field name
mxSetFieldSet field value in structure array, given index and field name
mxGetNumberOfFieldsNumber of fields in structure array
mxGetFieldNameByNumberPointer to field name from structure array, given field number
mxGetFieldNumberField number from structure array, given field name
mxGetFieldByNumberPointer to field value from structure array, given index and field number
mxSetFieldByNumberSet field value in structure array, given index and field number
mxAddFieldAdd field to structure array
mxRemoveFieldRemove field from structure array
mxCreateCellMatrix2-D cell array
mxCreateCellArrayN-D cell array
mxIsCellDetermine whether mxArray is cell array
mxGetCellPointer to element in cell array
mxSetCellSet contents of cell array

mxArray 삭제 및 복제

mxDestroyArrayFree dynamic memory allocated by MXCREATE* functions
mxDuplicateArrayMake deep copy of array

mxArray 변환하기

모두 확장

mxMakeArrayComplexConvert real mxArray to complex, preserving real data
mxMakeArrayRealConvert complex mxArray to real, preserving real data
mxArrayToStringArray to string
mxArrayToUTF8StringArray to string in UTF-8 encoding
mxGetStringmxChar array to C-style string or Fortran character array
mxSetClassNameStructure array to MATLAB object array

데이터 메모리 관리

mxCallocAllocate dynamic memory for array, initialized to 0, using MATLAB memory manager
mxMallocAllocate uninitialized dynamic memory using MATLAB memory manager
mxReallocReallocate dynamic memory using MATLAB memory manager
mxFreeFree dynamic memory allocated by mxCalloc, mxMalloc, mxRealloc, mxArrayToString, or mxArrayToUTF8String functions

어설션

mxAssertCheck assertion value for debugging purposes
mxAssertSCheck assertion value without printing assertion text

상수

mxIsInfDetermine whether input is infinite
mxIsFiniteDetermine whether input is finite
mxIsNaNDetermine whether input is NaN (Not-a-Number)

도움말 항목

Pass Strings in C MEX File

This example shows how to pass strings to a MEX function built with the C Matrix API.

Pass Scalar Values in C MEX File

This example shows how to write a MEX file that passes scalar values.

Handle Sparse Arrays in C MEX File

This example shows how to populate a sparse matrix using the C Matrix API.

Handle 8-, 16-, 32-, and 64-Bit Data in C MEX File

This example shows how to use unsigned 16-bit integers in a MEX file using the C Matrix API.

Pass Structures and Cell Arrays in C MEX File

This example shows how to pass structures and cell arrays to MEX files built with the C Matrix API.

Manipulate Multidimensional Numerical Arrays in C MEX Files

You can manipulate multidimensional numerical arrays by using typed data access functions like mxGetDoubles and mxGetComplexDoubles.