声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1465|回复: 8

[综合讨论] 行和列怎么搞反了?

[复制链接]
发表于 2006-12-1 19:08 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
a=[21,34,20;5,78,20;21,14,17;34,31,38]; b=[10,20,30,40]'; x=b\a
这个程序运算结果我觉得应该是 [0.7667;  1.1867; 0.8767]
但实际运行结果却是 [0.7667  1.1867  0.8767]

我觉得不对,因为x=b\a ,所以b=a*x,a为4*3;b为4*1 ,那么x应为3*1;
另外,a=[21,34,20;5,78,20;21,14,17;34,31,38]; b=[10,20,30,40]'; x=b\a; b=a*x
这个程序按理说是可以运行的,至少数学上没有错,为什么matlab不能运行?

[ 本帖最后由 ChaChing 于 2010-5-2 15:07 编辑 ]
回复
分享到:

使用道具 举报

发表于 2006-12-1 19:28 | 显示全部楼层
\ -- 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 编辑 ]
 楼主| 发表于 2006-12-1 20:49 | 显示全部楼层
哦,但a=[21,34,20;5,78,20;21,14,17;34,31,38]; b=[10,20,30,40]'; x=b\a; b=a*x
这一程序如何修改呢?

都晕了,关键在于x=b\a的结果,这个程序是一本书上抄下来的
书上反复强调结果应该是列阵即:[ 0.7667; 1.1867; 0.8767]
但实际运行结果却是 [0.7667,  1.1867,  0.8767]
而且如果是行阵列,就违反矩阵的预算规则了,还请高人指点!先谢过了!

[ 本帖最后由 ChaChing 于 2010-5-2 16:58 编辑 ]
发表于 2006-12-1 22:00 | 显示全部楼层
书上错了,应该是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 编辑 ]

评分

1

查看全部评分

发表于 2006-12-1 22:24 | 显示全部楼层
呵呵 是这样的了!~

[ 本帖最后由 ChaChing 于 2010-5-2 16:55 编辑 ]
 楼主| 发表于 2006-12-2 10:02 | 显示全部楼层
那么左除和右除到底有什么区别呢?  一本书上是这么写的:
在MATLAB中矩阵的除法有两种形式:左除“\”和右除“/”。在传统的MATLAB算法中,右除是先计算矩阵的逆再相乘,而左除则不需要计算逆矩阵直接进行除运算。通常右除要快一点,但左除可避免被除矩阵的奇异性所带来的麻烦

看了书上的描述,似乎左除右除没有根本区别。
但根据这位朋友的介绍,a^-1*b=a\b(不能是a/b吧),那么左除右除应该有根本的区别。
这到底是怎么搞得。 请专家总结一下。

[ 本帖最后由 ChaChing 于 2010-5-2 17:05 编辑 ]
发表于 2006-12-2 22:25 | 显示全部楼层
见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.

还可以看到./和.\的在线帮助,这样你就全明白了
发表于 2006-12-4 19:12 | 显示全部楼层
a/b是a除以b,a\b是a被b除,实际上是b除以a,左除和右除完全是反过来了,这个要明确哦

评分

1

查看全部评分

发表于 2006-12-5 07:48 | 显示全部楼层
原帖由 sunning 于 2006-12-4 19:12 发表
a/b是a除以b,a\b是a被b除,实际上是b除以a,左除和右除完全是反过来了,这个要明确哦


说的好,正确!
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-10-3 21:21 , Processed in 0.052506 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表