Writing a Simulink.Signal directly from a S-Function

7 views (last 30 days)
Is it possible to write a Simulink.Signal directly from a C MEX S-Function smilar to a Data-Store-Write-Block? If yes, whats the command to do this? The S-Function should not have any output ports to the Simulink model.

Answers (2)

Jarrod Rivituso
Jarrod Rivituso on 8 Apr 2011
Are you asking whether you can write values to a data store memory element from within an S-function? If so, I personally do not know how, but my workaround would be to have an S-function output that went directly to a data store write block. You could wrap the S-function and Data Store Write block in a subsystem so the block appeared not to have an output port.
If you are asking about creating a Simulink.Signal object from within an S-function, then I do not think that can be done. Furthermore, I'm not sure why you would do that. Simulink.Signal objects define signal properties in an object that is separate from the model. They do not represent the actual signal value over time. They generally are defined prior to the model simulation, and do not change during the simulation run-time (which is when the S-function would execute).

Jiang Xin
Jiang Xin on 24 Aug 2014
The S-Function macros in simstruc.h actually provides way to do so, e.g., using ssWriteToDataStore, but I'm not sure how to use them properly, may be some internal documents from Mathworks is needed

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!