This example shows how to select a target for a Simulink® model, generate C code for real-time simulation, and view generated files.
The model represents an 8-bit counter that feeds a triggered subsystem that is parameterized by constant blocks
Output represent I/O for the model. The
Amplifier subsystem amplifies the input signal by gain factor
K, which updates when signal
1. Open the model. For example, type the following commands at the MATLAB® command prompt.
2. Open the Configuration Parameters dialog box from the model editor by clicking Simulation > Configuration Parameters.
Alternately, type the following commands at the MATLAB® command prompt.
cs = getActiveConfigSet(model); openDialog(cs);
3. Select the Code Generation node.
4. In the Target Selection pane, click Browse to select a target.
You can generate code for a particular target environment or purpose. Some built-in targeting options are provided using system target files, which control the code generation process for a target.
5. Select the Generic Real-Time (GRT) target and click Apply.
Optionally, in the Code Generation Advisor pane set the Select objective field to Execution efficiency or Debugging. Then click Check model... to identify and systematically change parameters to meet your objectives.
6. In the Code Generation pane, click Build to generate code.
7. View the code generation report that appears.
The report includes links to model files such as
rtwdemo_rtwintro.c and associated utility and header files.
The figure below contains a portion of
8. Close the model.