Matlab Coder Data Types

1 次查看(过去 30 天)
Elijah Dewey
Elijah Dewey 2019-8-27
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 CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by