2016年9月12日 星期一

Matlab Coder-Infinite Array Size

In here, we introduce infinite array size instead of fixed. If we set the data types to Inf. array size, the coder will enforce to use dynamic memory allocation. We will see that the generated files may have many unfamiliar data types such as creal32_T and real32_T. These types are defined by the system, and we can go to a generated file called rtwtypes.h to check their definitions. If the size is set to infinite, we will see another definition file called XXX_types.h, where XXX is the file name.This file declare/define many methods to allocate memory, and we should choose one to use (depending on the data types).

Example
Matlab function is shown below:
In this example, the data type is complex single precision and the size is 1 x infinite vector.

The main program (Xcode):
The emxArray_real32_T *a = emxCreate_real32_T(1,SIZE) means memory allocation, which is declared in XXX_types.h. Note that different data types have different declarations or definitions. For example, if the intended data type is double and complex, then we should replace real_32 T with creal_T (see rtwtypes.h). 

Notice: We should at least include two head files, wise_product.h and wise_product_types.h before building the project.

The result is shown below:


沒有留言:

張貼留言