Main Content

Optimize Generated Code for Complex Signals

This example shows how Simulink® Coder™ handles complex signals efficiently. To view the data types of the signals, update the model. On the Debug menu, select Update Model. Complex signals are represented as structures in generated code. Simulink Coder performs various optimizations on these structures. For example:

  • Expression Folding: Gain and Sum operations on the complex signal are folded into a single expression.

  • For-loop fusion: Two separate for-loops, one for the complex signal and one for noncomplex signal, are combined into a single for-loop.

  • Inlined block parameters: The value of Gain block "pi" is inlined in the expression of the complex Gain-Sum.

Because of optimizations such as these, the code generated for complex and noncomplex signals is equally efficient.

Example Model

model='OptimizeComplexSignals';
open_system(model);

Related Topics