声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1674|回复: 4

[编程技巧] mtimes - Inner matrix dimensions must agree

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

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

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

x
>> k=0:0.01:1;
>> t=(3337-2250*k)/50*(2213-1400*k)
??? Error using ==> mtimes
Inner matrix dimensions must agree.

[ 本帖最后由 ChaChing 于 2009-7-12 18:07 编辑 ]
回复
分享到:

使用道具 举报

发表于 2009-7-12 09:13 | 显示全部楼层
LZ一定知道有点乘(.*)这一说吧,出错原因就是因为点乘!
t=(3337-2250*k)/50.*(2213-1400*k);

??? Error using ==> mtimes
一般出现这个错误都是由于没有用点乘,所以在用矩阵相乘时一定要注意!

评分

1

查看全部评分

 楼主| 发表于 2009-7-12 09:44 | 显示全部楼层

回复 沙发 ch_j1985 的帖子

谢谢!
还有一个问题,为什么只有一个地方要加点,如果
t=(3337-2250*k)/2213-1400*k);
的话应该把点加在哪里呢?

问题解决了,谢谢!

[ 本帖最后由 ChaChing 于 2009-12-17 21:46 编辑 ]
发表于 2009-7-12 10:04 | 显示全部楼层


t1=(3337-2250*k)./(2213-1400*k);
t2=(3337-2250*k).\(2213-1400*k);
t3=(3337-2250*k)\(2213-1400*k);
t4=(3337-2250*k)/(2213-1400*k);
这四个都可以运行出结果,但是结果不同!原因我也说不清楚……:@Q
数和矩阵相乘是可以不用点乘的
个人观点,仅供参考!
发表于 2009-7-12 16:07 | 显示全部楼层

回复 5楼 ch_j1985 的帖子

\
Matrix left division. A\B solves the symbolic linear equations A*X=B for X. Note that A\B is roughly equivalent to inv(A)*B. Warning messages are produced if X does not exist or is not unique. Rectangular matrices A are allowed, but the equations must be consistent; a least squares solution is not computed.

.\
Array left division. A.\B is the matrix with entries B(i,j)/A(i,j). A and B must have the same dimensions, unless one is scalar.

/
Matrix right division. B/A solves the symbolic linear equation X*A=B for X. Note that B/A is the same as (A.'\B.').'. Warning messages are produced if X does not exist or is not unique. Rectangular matrices A are allowed, but the equations must be consistent; a least squares solution is not computed.

./
Array right division. A./B is the matrix with entries A(i,j)/B(i,j). A and B must have the same dimensions, unless one is scalar.

评分

1

查看全部评分

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-9-22 08:24 , Processed in 0.060163 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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