MATLAB Answers

Is there an example of how to pass a string as a parameter into a C++-MEX S-function in Simulink?

40 views (last 30 days)
Fanny Benoist
Fanny Benoist on 27 Feb 2018
Answered: Nils Gerke on 31 Aug 2018
There is an example for c-MEX Sfunction but is there the same for C++ ?

Answers (1)

Nils Gerke
Nils Gerke on 31 Aug 2018
Here's a working example:
const mxArray* pArrayValue = ssGetSFcnParam(S,0);
const char* pCharArray = mxArrayToString(pArrayValue);
std::string string_1(pCharArray);
Make sure that you pass a char array as parameter in single quotes.
'Hello World'
"Hello World"


Sign in to comment.

Sign in to answer this question.