简体   繁体   English

错误:水平尺寸不匹配(4x4 与 1x4)

[英]error: horizontal dimensions mismatch (4x4 vs 1x4)

Why there is an error in the below code?为什么下面的代码有错误? I have tried to convert a row of the matrix B into a column of it.我试图将矩阵B的一行转换为它的一列。

B=[B 20*B(:,1)]
B =

      1      2      3     20
     10     20     30    200
      7      8      9    140
    100    200    300   2000

B=[B,B(1,:)]

error: horizontal dimensions mismatch (4x4 vs 1x4)错误: horizontal dimensions mismatch (4x4 vs 1x4)

B(1,:) is 1x4 as dimensions B(1,:) 的尺寸为 1x4

   1      2      3     20

While B is 4x4而 B 是 4x4

      1      2      3     20
     10     20     30    200
      7      8      9    140
    100    200    300   2000

and you are asking Octave to make a matrix like你要求 Octave 制作一个像

      1      2      3     20       1      2      3     20
     10     20     30    200
      7      8      9    140
    100    200    300   2000

that clearly does not work.这显然是行不通的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM