How to feed ZeroMQ data into Simulink via S-functions

This example builds on our previous S-function example and shows how to feed data from a ZeroMQ publisher into Simulink via S-functions.

I recommend against using cppzmq because Simulink tends to have issues with C++ exceptions. Instead, we use the C API of ZeroMQ.

This particular example receives a double value from a ZeroMQ publisher (as a string, such as "-10.2345") and outputs it to a Simulink output port.

I recommend using simulation stop time = inf here. This means, however, that the scopes don’t work properly. Using display

Simulink ZMQ example setup

S-function implementation

Compile this using

Test data producer

This simple C++ program sends values to the ZeroMQ publisher.

and run in the background.


Check out similar posts by category: Matlab/Simulink, C/C++