linsolve
Solve a linear system of equations.
Syntax
x = linsolve(A,b)
x = linsolve(A,b,opt)
Inputs
- A
- The left-hand side matrix.
- b
- The right-hand side vector or matrix.
- opt
- Options argument. See Comments.
Outputs
- x
- The solution vector or matrix.
Example
Positive definite example.
a=[3,1;1,3];
b=[1;2];
opt = struct('POSDEF', {true});
x=linsolve(a,b,opt)
x = [Matrix] 2 x 1
0.12500
0.62500
Rectangular example.
a=[1,2;3,4;5,8];
b=[1;2;3];
opt = struct('RECT', {true});
x=linsolve(a,b,opt)
x = [Matrix] 2 x 1
0.50000
0.08333
Comments
- POSDEF: positive definite
- RECT: general rectangular