ldivide, .\

Syntax

Description

x = B.\A
divides each element of A by the corresponding element of
B. The sizes of A and
B must be the same or be compatible.

If the sizes of A and B are compatible,
then the two arrays implicitly expand to match each other. For example, if one
of A or B is a scalar, then the scalar is
combined with each element of the other array. Also, vectors with different
orientations (one row vector and one column vector) implicitly expand to form a
matrix.

x = ldivide(B,A)
is an alternative way to divide A by
B, but is rarely used. It enables operator overloading for
classes.

Input Arguments

A, B — Operandsscalars | vectors | matrices | multidimensional arrays

Operands, specified as scalars, vectors, matrices, or multidimensional
arrays. Numeric inputs A and B must
either be the same size or have sizes that are compatible (for example,
A is an M-by-N
matrix and B is a scalar or
1-by-N row vector). For more
information, see Compatible Array Sizes for Basic Operations.

If A or B is an integer data
type, then the other input must be the same integer type or be a
scalar double. Operands with an integer data type cannot be
complex.

If A and B are duration
arrays, then they must be the same size unless one is a
scalar.

Compatibility Considerations

Implicit expansion change affects arguments for operators

Behavior changed in R2016b

Starting in R2016b with the addition of implicit expansion, some combinations of arguments for basic operations that previously returned errors now produce results. For example, you previously could not add a row and a column vector, but those operands are now valid for addition. In other words, an expression like [1 2] + [1; 2] previously returned a size mismatch error, but now it executes.

If your code uses element-wise operators and relies on the errors that MATLAB previously returned for mismatched sizes, particularly within a try/catch block, then your code might no longer catch those errors.

This website uses cookies to improve your user experience, personalize content and ads, and analyze website traffic. By continuing to use this website, you consent to our use of cookies. Please see our Privacy Policy to learn more about cookies and how to change your settings.