Mask s-function with datatype selector and register datatype in s-function
2 views (last 30 days)
Show older comments
Hello,
I would like to mask an s-function with a datatype selector:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/885740/image.png)
The datatype can to be selected be a standard matlab build in datatype, a bus or an enumeration.
How would I be able to retrieve the datatypeID of the selected datatype in the mask in the s-function and register it, so I can retrieve its size with ssGetDataTypeSize()?
Thank you in advance!
Kind regards,
Brecht
2 Comments
Benjamin Thompson
on 8 Feb 2022
Why does the mask care about the data type? The S-Function can get the data type by calling ssGetInputPortDataType, and get the size, and if you like that data type, you proceed. If you do not, call ssPrintf or ssSetErrorStatus.
Answers (1)
Benjamin Thompson
on 28 Feb 2022
Busses are treated a lot differently as Simulink marshals data to pass to or from an S-Function. So what you are describing cannot extend to busses. See the Busses section in the article "Configure C/C++ S-Function Features". For the other basic data types you can have the S-Function call ssGetInputPortDataType or ssGetOutputPortDatatype and use the result to determine how to handle the pointers you get when calling ssGetInputPortSignal or ssGetOutputPortSignal.
0 Comments
See Also
Categories
Find more on Configure Block Features for MATLAB S-Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!