行和列怎么搞反了?
a=; b='; x=b\a这个程序运算结果我觉得应该是
但实际运行结果却是
我觉得不对,因为x=b\a ,所以b=a*x,a为4*3;b为4*1 ,那么x应为3*1;
另外,a=; b='; x=b\a; b=a*x
这个程序按理说是可以运行的,至少数学上没有错,为什么matlab不能运行?
[ 本帖最后由 ChaChing 于 2010-5-2 15:07 编辑 ] \ -- Backslash or matrix left division. If A is a square matrix, A\B 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 AX = B computed by Gaussian elimination. A warning message is displayed if A is badly scaled or nearly singular. See the reference page for mldivide for more information.
[ 本帖最后由 ChaChing 于 2010-5-2 11:21 编辑 ] 哦,但a=; b='; x=b\a; b=a*x
这一程序如何修改呢?
都晕了,关键在于x=b\a的结果,这个程序是一本书上抄下来的
书上反复强调结果应该是列阵即:[ 0.7667; 1.1867; 0.8767]
但实际运行结果却是
而且如果是行阵列,就违反矩阵的预算规则了,还请高人指点!先谢过了!
[ 本帖最后由 ChaChing 于 2010-5-2 16:58 编辑 ] 书上错了,应该是a\b,因为
a*x=b
x=a^-1*b =a\b
这样解才是3*1的阵,若b\a=b^-1*a,这 b 不是方阵,没有逆
你把运行结果和这个方程解的计算结果比较一下就知道了
[ 本帖最后由 ChaChing 于 2010-5-2 17:02 编辑 ] 呵呵 是这样的了!~
[ 本帖最后由 ChaChing 于 2010-5-2 16:55 编辑 ] 那么左除和右除到底有什么区别呢?一本书上是这么写的:
在MATLAB中矩阵的除法有两种形式:左除“\”和右除“/”。在传统的MATLAB算法中,右除是先计算矩阵的逆再相乘,而左除则不需要计算逆矩阵直接进行除运算。通常右除要快一点,但左除可避免被除矩阵的奇异性所带来的麻烦
看了书上的描述,似乎左除右除没有根本区别。
但根据这位朋友的介绍,a^-1*b=a\b(不能是a/b吧),那么左除右除应该有根本的区别。
这到底是怎么搞得。 请专家总结一下。
[ 本帖最后由 ChaChing 于 2010-5-2 17:05 编辑 ] 见Matlab的在线帮助
\ 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 computed by
Gaussian elimination. 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.
和
/ Slash or right matrix divide.
A/B is the matrix division of B into A, which is roughly the
same as A*INV(B) , except it is computed in a different way.
More precisely, A/B = (B'\A')'. See MLDIVIDE for details.
C = MRDIVIDE(A,B) is called for the syntax 'A / B' when A or B is an
object.
还可以看到./和.\的在线帮助,这样你就全明白了 a/b是a除以b,a\b是a被b除,实际上是b除以a,左除和右除完全是反过来了,这个要明确哦 原帖由 sunning 于 2006-12-4 19:12 发表
a/b是a除以b,a\b是a被b除,实际上是b除以a,左除和右除完全是反过来了,这个要明确哦
说的好,正确!
页:
[1]