MATLAB Examples

Generating Structured Text for Stateflow® Chart with Absolute Time Temporal Logic

This model shows the code generated for a Stateflow chart which uses absolute time temporal logic. Simulate the model. Click on the scope to observe the "pulse" output.

Open up the "Temporal" Stateflow chart. Notice that this chart uses absolute time temporal logic operators like 'after' and 'before'. These operators are mapped to Structured Text timer operations in the generated code.

You can generate PLC Structured Text code for this chart by right-clicking on the chart and select PLC Code -> Generate Code for Subsystem

Alternatively, you can use the following command generatedFiles = plcgeneratecode('plcdemo_sf_abs_time/Temporal');

After the code generation, the Diagnostic Viewer window is displayed with hyperlinks to the generated code files. You can open the generated files by clicking on the links.