MATLAB Answers

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

42 ビュー (過去 30 日間)
Fanny Benoist
Fanny Benoist 2018 年 2 月 27 日
回答済み: Nils Gerke 2018 年 8 月 31 日
There is an example for c-MEX Sfunction but is there the same for C++ ?

回答 (1 件)

Nils Gerke
Nils Gerke 2018 年 8 月 31 日
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"

  0 件のコメント


Community Treasure Hunt

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

Start Hunting!

Translated by