Documentation Center

  • Trial Software
  • Product Updates


Divide one input by another


Math Operations


Supported Block Operations

The Divide block outputs the result of dividing its first input by its second. The inputs can be scalars, a scalar and a nonscalar, or two nonscalars that have the same dimensions. The Divide block is functionally a Product block that has two block parameter values preset:

  • Multiplication: Element-wise(.*)

  • Number of Inputs: */

Setting non-default values for either of those parameters can change a Divide block to be functionally equivalent to a Product block or a Product of Elements block. See the documentation of those two blocks for more information.

Expected Differences Between Simulation and Code Generation

If any of the Divide block inputs contains a NaN or inf value, or if the block generates NaN or inf during execution, you might see different results when you compare the block simulation results with the generated code. This difference is due to the nonfinite NaN or inf values. In such cases, inspect your model configuration and eliminate the conditions that produce NaN or inf.

Code Optimizations

The Simulink® Coder™ build process provides efficient code for matrix inverse and division operations. The following summary describes the benefits and when each benefit is available:

BenefitSmall matrices
(2-by-2 to 5-by-5)
Medium matrices
(6-by-6 to 20-by-20)
Large matrices
(larger than 20-by-20)
Faster code execution time, compared to R2011a and earlier releasesYesNoYes
Reduced ROM and RAM usage, compared to R2011a and earlier releasesYes, for real valuesYes, for real valuesYes, for real values
Reuse of variablesYesYesYes
Dead code eliminationYesYesYes
Constant foldingYesYesYes
Expression foldingYesYesYes
Consistency with MATLAB® Coder resultsYesYesYes

For blocks that have three or more inputs of different dimensions, the code might include an extra buffer to store temporary variables for intermediate results.

Parameters and Dialog Box

The Divide block has the same parameters and dialog box as the Product block. If all you need is to divide two inputs to create an output, you can use the Divide block with default parameter values. If you need additional capabilities, see the Product block documentation, which also describes the capabilities of the Divide block's Signal Attributes Pane.


The following examplesexamples show the output of the Divide block for some typical inputs using default block parameter values.

Was this topic helpful?