Why does adding a space give vertcat error?

조회 수: 3 (최근 30일)
Ashish Uniyal
Ashish Uniyal 2021년 10월 10일
편집: G A 2021년 10월 10일
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에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by