Documentation

rdivide, ./

Right-array division

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

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.

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 = fi(magic(3))
a=3×3 object
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=3×3 object
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

If inputs A and B are not the same size, one of them must be a scalar value.

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

If inputs A and B are not the same size, one of them must be a scalar value.

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, 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.

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.

Extended Capabilities

C/C++ Code GenerationGenerate C and C++ code using MATLAB® Coder™. 