Is there an example of how to pass a string as a parameter into a C++-MEX S-function in Simulink?
조회 수: 9 (최근 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!