# rdivide, ./

Right-array division

## Syntax

``X = A./B``
``X = rdivide(A,B)``

## Description

example

````X = A./B` performs right-array division by dividing each element of `A` by the corresponding element of `B`. ```
````X = rdivide(A,B)` is an alternative way to execute `X = A./B`.```

## Examples

collapse all

This example shows how perform right-array division on a 3-by-3 magic square of fi objects. Each element of the 3-by-3 magic square is divided by the corresponding element in the 3-by-3 input array b.

The `rdivide` function outputs a 3-by-3 array of signed fi objects, each of which has a word length of 16 bits and fraction length of 11 bits.

`a = fi(magic(3))`
```a = 8 1 6 3 5 7 4 9 2 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 11 ```
`b = int8([3 3 4; 1 2 4 ; 3 1 2 ])`
```b = 3x3 int8 matrix 3 3 4 1 2 4 3 1 2 ```
`c = a./b `
```c = 2.6665 0.3335 1.5000 3.0000 2.5000 1.7500 1.3335 9.0000 1.0000 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 11 ```

## Input Arguments

collapse all

Numerator, specified as a scalar, vector, matrix, or multidimensional array. Inputs `A` and `B` must either be the same size or have sizes that are compatible. For more information, see Compatible Array Sizes for Basic Operations.

If `A` is complex, the real and imaginary parts of `A` are independently divided by `B`.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `logical` | `fi`
Complex Number Support: Yes

Denominator, specified as a scalar, vector, matrix, or multidimensional array. Inputs `A` and `B` must either be the same size or have sizes that are compatible. For more information, see Compatible Array Sizes for Basic Operations.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `logical` | `fi`

## Output Arguments

collapse all

Quotient, returned as a scalar, vector, matrix, or multidimensional array.

The following table shows the rules used to assign property values to the output of the `rdivide` function.

Output PropertyRule
`Signedness`

If either input is `Signed`, then the output is `Signed`.

If both inputs are `Unsigned`, then the output is `Unsigned`.

`WordLength`

The output word length equals the maximum of the input word lengths.

`FractionLength`

For `c = a./b`, the fraction length of output `c` equals the fraction length of `a` minus the fraction length of `b`.

## Algorithms

The following table shows the rules the `rdivide` function uses to handle inputs with different data types.

CaseRule
Interoperation of `fi` objects and built-in integers

Built-in integers are treated as fixed-point objects.

For example, `B = int8(2)` is treated as an `s8,0` `fi` object.

Interoperation of `fi` objects and constants

MATLAB® for code generation treats constant integers as fixed-point objects with the same word length as the `fi` object and a fraction length of `0`.

Interoperation of mixed data types

Similar to all other `fi` object functions, when inputs `a` and `b` have different data types, the data type with the higher precedence determines the output data type. The order of precedence is as follows:

1. `ScaledDouble`

2. `Fixed-point`

3. Built-in `double`

4. Built-in `single`

When both inputs are `fi` objects, the only data types that are allowed to mix are `ScaledDouble` and `Fixed-point`.

## Version History

Introduced in R2009a

expand all

Behavior changed in R2022a