Matlab Coder Data Types
1 回表示 (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
回答 (1 件)
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!
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!