Is there an example of how to pass a string as a parameter into a C++-MEX S-function in Simulink?
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
There is an example for c-MEX Sfunction but is there the same for C++ ?
1 comentario
Nils Gerke
el 30 de Ag. de 2018
Editada: Nils Gerke
el 30 de Ag. de 2018
An Answer to this would solve my question as well: https://de.mathworks.com/matlabcentral/answers/414621-s-function-string-parameter-c
Respuestas (1)
Nils Gerke
el 31 de Ag. de 2018
Here's a working example:
const mxArray* pArrayValue = ssGetSFcnParam(S,0);
const char* pCharArray = mxArrayToString(pArrayValue);
std::string string_1(pCharArray);
mexPrintf(string_1.c_str());
Make sure that you pass a char array as parameter in single quotes.
'Hello World'
not
"Hello World"
0 comentarios
Ver también
Categorías
Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!