Calculate square root, signed square root, or reciprocal of square root
Math Operations
You can select one of the following functions from the Function parameter list.
Function  Description  Mathematical Expression  MATLAB^{®} Equivalent 

sqrt  Square root of the input 
 sqrt 
signedSqrt  Square root of the absolute value of the input, multiplied by the sign of the input 
 — 
rSqrt  Reciprocal of the square root of the input 
 — 
The block output is the result of applying the function to the input. Each function supports:
Scalar operations
Elementwise vector and matrix operations
The block accepts input signals of the following data types:
Function  Input Data Types  Restrictions 


 None 

 When the input is an integer or fixedpoint type, the output must be floating point. 

 None 
The block accepts real and complex inputs of the following types:
Function  Types of Real Inputs  Types of Complex Inputs 

 Any, except for fixedpoint inputs that are negative or have nontrivial slope and nonzero bias  Any, except for fixedpoint inputs 
 None  
 None 
The block output:
Uses the data type that you specify for Output data type
Is real or complex, depending on your selection for Output signal type
Specify the mathematical function. The block icon changes to match the function you select.
Function  Block Icon 

sqrt  
signedSqrt  
rSqrt 
Specify the output signal type of the block as auto
, real
,
or complex
.
Function  Input Signal Type  Output Signal Type  

Auto  Real  Complex  








 








 









Note:
This parameter is not visible in the block dialog box unless
it is explicitly set to a value other than 
Note:
The parameters in the Algorithm pane are
available only when you set Function to 
Specify the method for computing the reciprocal of a square root.
Method  Data Types Supported  When to Use This Method  

Exact  Floating point If you use a fixedpoint or builtin integer type, an upcast to a floatingpoint type occurs.  You do not want an approximation.
 
NewtonRaphson  Floatingpoint, fixedpoint, and builtin integer types  You want a fast, approximate calculation. 
The Exact
method provides results
that are consistent with MATLAB computations.
Note:
The algorithms for 
Specify the number of iterations to perform the NewtonRaphson algorithm. The default value is 3.
This parameter is not available when you select Exact
for Method.
Note: If you enter 0, the block output is the initial guess of the NewtonRaphson algorithm. 
Specify the data type for intermediate results (available only
when you set Function to sqrt
or rSqrt
on
the Main pane). You can set the data type to:
A rule that inherits a data type, for example, Inherit:Inherit
via internal rule
The name of a builtin data type, for example, single
The name of a data type object, for example, a Simulink.NumericType
object
An expression that evaluates to a data type, for example, fixdt(1,16,0)
Follow these guidelines on setting an intermediate
data type explicitly for the square root function, sqrt
:
Input and Output Data Types  Intermediate Data Type 

Input or output is double.  Use double. 
Input or output is single, and any nonsingle data type is not double.  Use single or double. 
Input and output are fixed point.  Use fixed point. 
Follow these guidelines on setting an intermediate
data type explicitly for the reciprocal square root function, rSqrt
:
Input and Output Data Types  Intermediate Data Type 

Input is double and output is not single.  Use double. 
Input is not single and output is double.  Use double. 
Input and output are fixed point.  Use fixed point. 
Caution
Do not set Intermediate results data type to
Under these conditions, selecting To avoid this error, convert the input signal from a floatingpoint to fixedpoint data type. For example, insert a Data Type Conversion block in front of the Sqrt block to perform the conversion. 
Specify the output data type. You can set the data type to:
A rule that inherits a data type, for example, Inherit:Inherit
via back propagation
The name of a builtin data type, for example, single
The name of a data type object, for example, a Simulink.NumericType
object
An expression that evaluates to a data type, for example, fixdt(1,16,0)
Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Output data type parameter.
See Control Signal Data Types for more information.
Specify the minimum value that the block can output. The default
value is []
(unspecified). Simulink^{®} uses this
value to perform:
Simulation range checking (see Signal Ranges)
Automatic scaling of fixedpoint data types
Specify the maximum value that the block can output. The default
value is []
(unspecified). Simulink uses this
value to perform:
Simulation range checking (see Signal Ranges)
Automatic scaling of fixedpoint data types
Select to lock the output data type setting of this block against changes by the FixedPoint Tool and the FixedPoint Advisor. For more information, see Use Lock Output Data Type Setting.
Specify the rounding mode for fixedpoint operations. For more information, see Rounding. in the FixedPoint Designer™ documentation.
Action  Reasons for Taking This Action  What Happens for Overflows  Example 

Select this check box.  Your model has possible overflow, and you want explicit saturation protection in the generated code.  Overflows saturate to either the minimum or maximum value that the data type can represent.  The maximum value that the 
Do not select this check box.  You want to optimize efficiency of your generated code. You want to avoid overspecifying how a block handles outofrange signals. For more information, see Checking for Signal Range Errors.  Overflows wrap to the appropriate value that is representable by the data type.  The maximum value that the 
When you select this check box, saturation applies to every internal operation on the block, not just the output or result. Usually, the code generation process can detect when overflow is not possible. In this case, the code generator does not produce saturation code.
Suppose that you have the following model:
When the input to the Sqrt block is negative and the Output
signal type is auto
or real
,
the sqrt
function outputs NaN
.
However, setting Output signal type to complex
produces
the correct answer.
Suppose that you have the following model:
When the input to the Sqrt block is negative, the block output
is the same for any Output signal type setting.
If you change the first Display block
format from short
to decimal
(Stored Integer)
, you see the value of the imaginary
part for the complex output.
Suppose that you have the following model:
In the Sqrt block dialog box, assume that the following parameter settings apply:
Parameter  Setting 

Method  NewtonRaphson 
Number of iterations  1 
Intermediate results data type  Inherit:Inherit from input 
After one iteration of the NewtonRaphson algorithm, the block output is within 0.0004 of the final value (0.4834).
Suppose that you have the following model:
In the Sqrt block dialog box, assume that the following parameter settings apply:
Parameter  Setting 

Method  NewtonRaphson 
Number of iterations  1 
Intermediate results data type  Inherit:Inherit from input 
After one iteration of the NewtonRaphson algorithm, the block output is within 0.0459 of the final value (0.4834).
Data Types  Double  Single  Base Integer  FixedPoint 
Sample Time  Inherited from driving block 
Direct Feedthrough  Yes 
Multidimensional Signals  Yes 
VariableSize Signals  Yes 
ZeroCrossing Detection  No 
Code Generation  Yes 