Vah*_*ili 12 ubuntu operators matrix octave
在八度音阶3.6.2中,我有一个矩阵X=[1 2 3; 2 4 5; 2 6 5; 2 3 7; 3 6 8; 2 4 6; 3 6 8; 4 7 10],我想计算X均值(X),这给了我:
octave:2> X-mean(X)
warning: operator -: automatic broadcasting operation applied
ans =
-1.37500 -2.75000 -3.50000
-0.37500 -0.75000 -1.50000
-0.37500 1.25000 -1.50000
-0.37500 -1.75000 0.50000
0.62500 1.25000 1.50000
-0.37500 -0.75000 -0.50000
0.62500 1.25000 1.50000
1.62500 2.25000 3.50000
Run Code Online (Sandbox Code Playgroud)
但是,当我在另一台机器上尝试相同的命令时,它会抱怨矩阵的大小不匹配:
error: operator -: nonconformant arguments (op1 is 7x3, op2 is 1x3)
Run Code Online (Sandbox Code Playgroud)
知道如何激活在第一种情况下应用的" 自动广播操作 "吗?(八度版本是相同的!)
emu*_*emu 19
您可以通过呼叫明确请求广播bsxfun(operation, A, B),因此在您的情况下:
bsxfun(@minus, X, mean(X))
Run Code Online (Sandbox Code Playgroud)
小智 6
很抱歉这么晚来.虽然使用相同的版本,但您可能会将第二台机器设置不同.
查看Octave Broadcasting文档,您可以直接设置警告beahaviour:
warning ("error", "Octave:broadcast");
与
warning ("off", "Octave:broadcast");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12616 次 |
| 最近记录: |