MATLAB: Is it possible to have a variable length string as an input of the Embedded MATLAB function in MATLAB 7.9 (R2009b)

egsemlcoderMATLAB

I would like to be able to pass a variable length string to my Embedded MATLAB function. This string represents the name of a file which should be opened and can therefore not be of fixed size.

Best Answer

It is possible to specify variable length strings as inputs in Embedded MATLAB. The input argument must be prototyped using the emlcode.egs command. Attached is an example that demonstrates how this can be implemented. In order to build the MEX-file you can use the following line of code:
emlc -eg {emlcoder.egs(char(0), [1, 100])} my_eml_fcn simple.c