11: Solve matrix equation Ax=b
Solve Ax=b (and check the solution) given thatA =
1 2 0 2 5 -1 4 10 -1
b =
7 8 9
Mathematica:
A = { {1,2,0}, {2,5,-1}, {4,10,-1} }
b = {7,8,9}
x = LinearSolve[ A, b ]
A . x (does equal b)
Matlab:
A = [ 1 2 0 ; 2 5 -1 ; 4 10 -1 ]
b = [ 7 8 9 ]
x = A\transpose(b)
A * x (does equal b)
Maple:
xxx
IDL:
A = [ [1,2,0], [2,5,-1], [4,10,-1] ]
b = [7,8,9]
svd, transpose(A), w,u,v
svbksb, u,w,v,b,x
print, x
print, x # A (does equal b)
>> help('\')
\ Backslash or left matrix divide.
A\B is the matrix division of A into B, which is roughly the
same as INV(A)*B , except it is computed in a different way.
If A is an N-by-N matrix and B is a column vector with N
components, or a matrix with several such columns, then
X = A\B is the solution to the equation A*X = B. A warning
message is printed if A is badly scaled or nearly singular.
A\EYE(SIZE(A)) produces the inverse of A.
If A is an M-by-N matrix with M < or > N and B is a column
vector with M components, or a matrix with several such columns,
then X = A\B is the solution in the least squares sense to the
under- or overdetermined system of equations A*X = B. The
effective rank, K, of A is determined from the QR decomposition
with pivoting. A solution X is computed which has at most K
nonzero components per column. If K < N this will usually not
be the same solution as PINV(A)*B. A\EYE(SIZE(A)) produces a
generalized inverse of A.
C = mldivide(A,B) is called for the syntax 'A \ B' when A or B is an
object.
See also ldivide, rdivide, mrdivide.
Overloaded methods:
sym/mldivide
StaticModel/mldivide
DynamicSystem/mldivide
timeseries/mldivide
Reference page in Help browser
doc mldivide
'CAE > Enjoy Programming' 카테고리의 다른 글
#Python에서 #module 사용하기 (0) | 2016.03.26 |
---|---|
#Python #class에서 #self의 사용법 (0) | 2016.03.26 |
Interpolation 예제 - UnivariateSpline (0) | 2012.01.15 |
Notes on Python variable scope (0) | 2012.01.02 |
How to use *args and **kwargs in Python (0) | 2012.01.02 |