Pergunta

I am currently using this code:

assert(isa(values,'double'));
assert(size(values, 1) <= 1000);

to persuade matlab coder to make values a one dimensional array. The end aim is to be able to interface with it via C# and PInvoke. This creates a C signature containing this:

const real_T values[1000], const int32_T values_size[1]

I seem to be able to use this even for one dimensional arrays where the lengths is less than 1000. Are there neater ways to achieve the above (i.e. assert that values is a one dimensional array of unlimited length)?

PS:

I have also used:

assert(all(size(values) == [1 Inf]));

but shelved this for now as the created struct seems to be very complicated (see also here) and I do not know how to populate it from C#.

Foi útil?

Solução

Matlab coder now seems to support dynamic memory allocation (that wasn't the case when I last used it around 2008).

A full example: http://www.mathworks.de/products/matlab-coder/examples.html?file=/products/demos/shipping/coder/coderdemo_atoms.html

Update: For dynamically sized arrays Matlab uses EMX data structures: http://www.mathworks.de/de/help/fixedpoint/ug/c-code-interface-for-unbounded-arrays-and-structure-fields.html

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top