Simulink PLC Coder
In Simulink, you can generate Structured Text using Simulink PLC Coder by right-clicking on a Subsystem block and selecting the PLC Coder > Generate Code for Subsystem option in the resulting context menu. In MATLAB, you can invoke the plcgeneratecode command, which lets you create scripts to generate Structured Text using an automated, repeatable build process.
With support for more than 130 Simulink blocks, all Stateflow constructs, and many Embedded MATLAB functions, Simulink PLC Coder can fully implement your control system models comprising feedback loops, mode and state logic, and math-intensive algorithms. You can use Simulink PLC Coder to convert discrete-time plant models into Structured Text for hardware-in-the-loop (HIL) testing. Alternatively, you can use Simulink Coder™ to generate C/C++ code for HIL testing with discrete-time or continuous-time models.