Is there an example of how to pass a string as a parameter into a C++-MEX S-function in Simulink?
10 ビュー (過去 30 日間)
古いコメントを表示
There is an example for c-MEX Sfunction but is there the same for C++ ?
1 件のコメント
Nils Gerke
2018 年 8 月 30 日
編集済み: Nils Gerke
2018 年 8 月 30 日
An Answer to this would solve my question as well: https://de.mathworks.com/matlabcentral/answers/414621-s-function-string-parameter-c
回答 (1 件)
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);
mexPrintf(string_1.c_str());
Make sure that you pass a char array as parameter in single quotes.
'Hello World'
not
"Hello World"
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!