User`s guide

Quick Start Tutorials
3-37
4 Click the Generate code button.
5 As before, Real-Time Workshop generates code in the example_grt_rtw
directory.
6 Edit example_grt_rtw/example.c and examine the function
example_output.
In the previous examples, the Gain block computation was computed in a
separate code statement and the result was stored in a temporary location
before the final output computation.
With
Eliminate superfluous temporary variables (Expression folding)
selected, there is a subtle but significant difference in the generated code: the
gain computation is incorporated (or “folded”) directly into the Outport
computation, eliminating the temporary location and separate code
statement. This computation is on the last line of the
example_output
function.
static void example_output(int_T tid)
{
real_T rtb_sin_out;
rtb_sin_out = example_P.SineWave_Amp *
sin(example_P.SineWave_Freq * example_M->Timing.t[0] +
example_P.SineWave_Phase) + example_P.SineWave_Bias;
example_Y.Out1 = rtb_sin_out * example_P.Gain_Gain;
}
In many cases, expression folding can incorporate entire model computations
into a single, highly optimized line of code. Expression folding is turned on by
default. Using this option will improve the efficiency of generated code.
HTML Code Generation Reports
When the Generate HTML report option under the Real-Time Workshop
General
tab is selected, a navigable summary of source files is produced
when the model is built (see figure below).