Is there an example of how to pass a string as a paramater into a C-MEX S-function in Simulink?
6 次查看(过去 30 天)
显示 更早的评论
Is there an example of how to pass a string as a paramater into a C-MEX S-function in Simulink?
采纳的回答
MathWorks Support Team
2010-2-3
There is an example showing of how to pass a string as a paramater into a C-MEX S-function. You can find the files linked below.
If you open up the S-function source file, you will notice the following lines in mdlOutputs:
buflen = mxGetN((ssGetSFcnParam(S, 3)))*sizeof(mxChar)+1;
String = mxMalloc(buflen);
status = mxGetString((ssGetSFcnParam(S, 3)), String,buflen);
mexPrintf("The string being passed as a Paramater is - %s\n ", String);
Here the first two lines allocate memory for the string that is being passed into the S-function. Then you would use mxGetString to store this string in a character array. In this example the parameter is being stored in a char * called "String". The parameter "buflen" will be the length of this string.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 String 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!