Is it possible to have strings as I/O for S-function blocks?
7 views (last 30 days)
Show older comments
MathWorks Support Team
on 6 Apr 2020
Edited: MathWorks Support Team
on 6 Oct 2025
There is an example model where I want to have that the Simulink S-Function block accepting inputs and outputs to a S-function as strings.
I was hoping to have the function below been modified as shown:
ssSetInputPortDataType( S, eIN_STRING, SS_UINT8 );
Modified version:
ssSetInputPortDataType( S, eIN_STRING, SS_STRING);
Is there a possibility to make this happen?
Accepted Answer
MathWorks Support Team
on 6 Oct 2025
Edited: MathWorks Support Team
on 6 Oct 2025
From R2020b:
It should be possible to register a string type in C-Mex S-functions using ssRegisterStringDataType and set the input port to the Data type ID output given by ssRegisterStringDataType.
There are other relevant APIs added for Strings in S-functions under the Data Type and Sample Time > Strings of this documentation.
MATLAB S-functions still don't support string data types as I/O.
Before R2020b:
Including a string I/O is a documented limitation of S-Functions for both MATLAB and C. Please see the following link:
It is suggest to use UINT8 as probably the best workaround.
0 Comments
More Answers (0)
See Also
Categories
Find more on Model, Block, and Port Callbacks 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!