Why does adding a space give vertcat error?

2 次查看(过去 30 天)
Although this works as expected
[1;1+1]
ans = 2×1
1 2
Inserting a space gives vertcat error for some reason
[1;1 +1]
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Why does this occur?

采纳的回答

G A
G A 2021-10-10
with a space, [1;1 +1] is interpreted as [1;1, +1]. [1;(1 +1)] will be OK.
  2 个评论
Ashish Uniyal
Ashish Uniyal 2021-10-10
Ah got it, thanks a lot! Although it's a bit unexpected with an operator sitting there.
G A
G A 2021-10-10
编辑:G A 2021-10-10
I found that
[1 + 1; 1 + 1]
ans =
2
2
[1 +1; 1 +1]
ans =
1 1
1 1
[1+1; 1+1]
ans =
2
2
[1+ 1; 1+ 1]
ans =
2
2
the same behaviour if the second number is imaginary as 1i

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by