Matlab Coder Data Types

1 回表示 (過去 30 日間)
Elijah Dewey
Elijah Dewey 2019 年 8 月 27 日
回答済み: Yogesh Khurana 2019 年 12 月 16 日
Hello,
I am trying to convert old MATLAB code from 6.5.1 to C using MATLAB Coder on 2019a. I also have old C code generated from the MATLAB code that was using Matlab Code Compiler but the data types are not listed. Is there a way to find the specific data types and lengths of array from the C code where it calls mxArray? Any help would be appreciated.

回答 (1 件)

Yogesh Khurana
Yogesh Khurana 2019 年 12 月 16 日
There are various components in the generated C MEX file. Please refer to the following link for more information on the components:
mxArray is part of one of the components defined in the link above. mxArray is C type for MATLAB array. While creating mxArray, there is a need to pass the size of mxArray as well as the data-type of mxArray. Please refer to the following code that defines mxArray in on the generated C code:
int numPts = (int) mxGetNumberOfElements(prhs[0]);
mxArray * labelsMx = mxCreateNumericMatrix(numPts, 1, mxINT32_CLASS, mxREAL);
int* labels = (int*) mxGetData(labelsMx);
Here numPts is defined by passing the size through command line at the time of calling the MEX C file. mxINT32_CLASS states that the data-type of the labelsMx is int32 (MATLAB data-type). And then at the final step the labelsMx is linked to lables variable in C that is of data-type int. So, here variable “labels” is the array of data-type int and size numPts.
Please refer to the following link for more information on mxCreateNumericMatrix and mxGetData:
Hope this helps!

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by