Target Language Compiler    

Generate and Run Code from the Model

  1. Make sure that simple_log.mdl is set up to generate code properly by opening the Simulation parameters dialog and clicking the Advanced tab. Make sure that Inline parameters is selected. The bug you will fix only appears when inline parameters are used.
  2. Click the Build button.
  1. C Source code is generated, compiled and linked. The MATLAB command window shows the progress of the build, which ends with these messages:

  1. Run the stand-alone model just created by typing
  1. This results in the messages

  1. Inspect results by placing the variables in your workspace; double-click on simple_log.mat in your Current Directory pane, then double-click on rt_yout (the stand-alone version of variable yout) in the Workspace pane.
  1. Compare rt_yout with yout. Do you notice any differences? Can you surmise what caused values in rt_yout to change?

    A look at the generated C code that the TLC placed in your build directory (/simple_log_grt_rtw) helps to identify the problem.

  1. Edit simple_log.c and look at its MdlOutputs function, which should appear as shown below:

Note the line near the end, rtb_first_output = 1.0;. How did a constant value get passed to the output when it was supposed to receive a variable that alternates between 1.0 and 0.0? Use the debugger to find out.


  Getting Started Start the Debugger and Explore Commands