How to generate a s-function which takes a string as input argument (before Matlab 2018)

Hi,
i want to have a s-function taking a string as input argument. Since i use Matlab 2017b and before Matlab 2018 strings are not a build-in Simulink type, i would like to know what is best practice for doing that. Until now i do the following:
def = legacy_code('initialize');
def.SFunctionName = 'testSFun';
def.OutputFcnSpec = 'test(double u1, uint8 p1[])';
So i use a uint8[] to pass the string to the function. In the corresponding c-file, in mdlRTW function i then use mxGetString. Unfortunately it does not work. If i type e.g. 'teststring' in the parameter field of the s-function block mask and then try to simulate, Simulink tells me
This parameter is an unsupported variable class such as a character vector, string, structure, cell, or an unsupported data type
What can i do?

Antworten (0)

Kategorien

Mehr zu Simulink Coder finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2017b

Gefragt:

am 3 Aug. 2018

Bearbeitet:

am 3 Aug. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by