Equivalent of [C{:}] for vertcat

1 回表示 (過去 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 日
cell2mat(A')

サインインしてコメントする。


KSSV
KSSV 2016 年 12 月 21 日
vertcat(A{:})
  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 Center および File ExchangeLogical についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by