| Contents | Index |
In addition to analyzing models with Model Advisor (see Get Advice About Optimizing Models for Code Generation), you can use a variety of other tools and techniques that work with any code format. Here are some particularly useful ones:
Run the slupdate command to automatically convert older models (saved by prior versions or by the current one) to use current features. For details about what slupdate does, type
help slupdate
Before building, set optimization flags for the compiler (for example, -O2 for gcc, -Ot for the Microsoft Visual C++ compiler).
Directly inline C/C++ S-functions into the generated code by writing a TLC file for the S-function. See Generated S-Function Block and the Target Language Compiler documentation for more information on inlining S-functions.
Use a Simulink data type other than double when possible. The available data types are Boolean, signed and unsigned 8-, 16-, and 32-bit integers, and 32- and 64-bit floats (a double is a 64-bit float). See Working with Data in the Simulink documentation for more information on data types. For a block-by-block summary, click showblockdatatypetable or type the command in the MATLAB Command Window.
Remove repeated values in lookup table data.
Use the Merge block to merge the output of signals wherever possible. This block is particularly helpful when you need to control the execution of function-call subsystems with a Stateflow chart. The following model shows an example of how to use the Merge block.

When more than one signal connected to a Merge block has a non-Auto storage class, all non-Auto signals connected to that block must be identically labeled and have the same storage class. When Merge blocks connect directly to one another, these rules apply to all signals connected to any of the Merge blocks in the group.
If you are licensed to use the Embedded Coder product, see also Configure Code Optimizations and in the Embedded Coder documentation.
![]() | Control Compiler Optimization Level and Specify Custom Optimization Settings | Control Memory Allocation for Time Counters | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |