Accelerating the pace of engineering and science

# rdivide

Right-array division (./)

c = rdivide(a,b)
c = a./b

## Description

c = rdivide(a,b) and c = a./b perform right-array division by dividing each element of a by the corresponding element of b. If inputs a and b are not the same size, one of them must be a scalar value.

The numerator input a can be complex, but the denominator b requires a real-valued input. If a is complex, the real and imaginary parts of a are independently divided by b.

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, the output is Signed.

If both inputs are Unsigned, 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.

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.

## Examples

In this example, you 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.

```a = fi(magic(3))
b = int8([3  3 4; 1 2 4 ; 3 1 2 ])
c = a./b```

The mrdivide 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 =

8     1     6
3     5     7
4     9     2

DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 11

b =

3    3    4
1    2    4
3    1    2

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
```