Equivalent of [C{:}] for vertcat

조회 수: 2 (최근 30일)
Luca Amerio
Luca Amerio 2016년 12월 21일
댓글: Matt J 2016년 12월 28일
To concatenate horizontally the content of a cell array we can use the very practice syntax [C{:}]. For example:
A = {(1:3) (4:7)};
B = [A{:}]
B =
1 2 3 4 5 6 7
Is there a way to obtain the same results in the vertical direction (except vertcat of course)
A = {(1:3)' (4:7)'};
B = ?
B =
1
2
3
4
5
6
7

채택된 답변

Matt J
Matt J 2016년 12월 21일
편집: Matt J 2016년 12월 21일
Well, it's not vertcat...
B=cat(1,A{:})
But no, I don't think there's a way purely with operator syntax.
  댓글 수: 1
Walter Roberson
Walter Roberson 2016년 12월 21일
Correct, there is no operator syntax for this.

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

José-Luis
José-Luis 2016년 12월 21일
편집: José-Luis 2016년 12월 21일
EDIT
cell2mat(A')
  댓글 수: 2
Luca Amerio
Luca Amerio 2016년 12월 21일
편집: Luca Amerio 2016년 12월 21일
This won't work if, as I did on purpose in the example, the vectors inside C are not all the same length.
Moreover, even if the are, the result is not the wanted one.
José-Luis
José-Luis 2016년 12월 21일

댓글을 달려면 로그인하십시오.


KSSV
KSSV 2016년 12월 21일
  댓글 수: 1
Luca Amerio
Luca Amerio 2016년 12월 21일
"except vertcat of course"
Thank you, but as [C{:}] is an equivalent for horzcat(C{:}), I was asking myself if there was such an equivalent for vertcat too..

댓글을 달려면 로그인하십시오.


Greg
Greg 2016년 12월 28일
Do exactly the same thing, then transpose B...
A = {(1:3) (4:7)}; B = [A{:}]'
  댓글 수: 1
Matt J
Matt J 2016년 12월 28일
This only works when the elements of A are row vectors, not column vectors, as in the OP's example.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by