Automatic Generation of Inputs Information for MATLAB Coder

Centre de Recherche en Informatique (CRI)
MINES ParisTech - PSL

Introduction
MATLAB Coder indded enables users to get C/C++/Mex version of their MATLAB routines. However, and this makes sense, we need to specify for each input its name, type, size bounds. This looks like the following
assert(isa(col,'double')); assert(all(size(col) >= [1000 1])); assert(all(size(col) <= [2000 1]));
The above line says that variable col is of a 2D (indeed 1D) array of between 1000 and 2000 values of type double. This will certainly helps MATLAB Coder to make correct assumptions and memory allocations, it is mandatory.
If you have lot of inputs including complex structures, then the task becomes tedious. Indeed, for a structure (type struct), you need to do the same inventory for all its fields, and recurse if necessary. For the sizes, you could estimate, but you probably need to run the code to get the right bounds.
Once you get all the information, then you need to write the corresponding lines as previously shown. Its gives something like this
```        function [pts, nb_pts] = Compute(lig, col)
%#codegen
assert(isa(lig,'double')); assert(all(size(lig) >= [1000 1]));assert(all(size(lig) <= [2000 1]))
assert(isa(col,'double')); assert(all(size(col) >= [1000 1]));assert(all(size(col) <= [2000 1]));
...
```
Tool for automatic generation
Here we provide a tool that will snoop your routine, collect/compute all required information and generate the assert lines that you will use within your MATLAB code to instruct MATLAB Coder.
```    f Consider a matlab function Outputs = MyFunction(Inputs_List)