Solve a system of linear equations. The matrix has to be square and real.
Syntax |
Description |
---|---|
x = solve(A, b); |
Returns solution for A x = b. |
x = solve(i, j, v, m, n, b); |
Returns solution for A x = b where A given in sparse format. |
Simultaneous solutions (multiple-column b) are supported. Result x will have same shape as input b.
Sparse format:
- i, j, v are vectors the same length of row indices, column indices and matrix values.
- m is the number of rows, n the number of columns. Requires m=n.
Example
This is a simple example of the command.
A = [1,2;3,4];
b = [1;2];
x = solve(A, b);
?x;
result:
0
0.5
See Also