This example shows how to simulate and generate code for the Controller subsystem from a speed cruise control model by using variable continuous step solver.
To start the simulation, click Run
To generate code for the Controller subsystem, use
generatedfiles = plcgeneratecode('plcdemo_cruise_control_continuous/Controller');
In this model, the model solver is set to variable-step continuous (ode45); the sample time of the controller subsystem is set to 0.05. To set the controller sample time, right click on the controller block and select Subsystem Parameters, on the Main tab, set the Sample time parameter. This method allows combined modeling of discrete-time controller and continuous-time plant in the same model with PLC code generation support.