pagemldivide

Solves linear systems page by page, A \ B for each page.

Category: Language Fundamentals > Operators and Elementary Operations

Syntax

X = pagemldivide(A, B)

For each page, solves A(:,:,k) * X(:,:,k) = B(:,:,k).

Description

It is the page-wise version of the \ operator, so pagemldivide(A, B) gives the same result as solving each page in a loop, including least squares for non-square pages. A size-1 page dimension is reused: a single matrix A can be applied to a stack of right-hand sides.

For the right-hand version X*A = B use pagemrdivide.

Input arguments

A
Array of coefficient pages, each m-by-n.
B
Right-hand sides, each page with m rows. Pages beyond the second dimension must match or be 1.

Output arguments

X
Solutions, each page with n rows.

Example

A = cat(3, [2 0; 0 2], [1 0; 0 4]);
B = cat(3, [2; 2], [4; 4]);
X = pagemldivide(A, B);
X(:, :, 1)
X(:, :, 2)
Output
ans = 2×1

     1
     1
ans = 2×1

     4
     1

See also

pagemrdivide pagemtimes \ mldivide