Dears,
T is a vector concatenated from T{J} (J=0:4000) which T{1}, T{2}, ... are not same size. How can I concatenate T as a vector?
Regards

2 件のコメント

Geoff Hayes
Geoff Hayes 2015 年 5 月 3 日
Sam - what are the T{k}? Are they scalars, vectors, matrices, strings or ..??
Sam sanati
Sam sanati 2015 年 5 月 3 日
Sorry, I forgot to mention. they are vectors.

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

 採用された回答

Jos (10584)
Jos (10584) 2015 年 5 月 3 日

3 投票

If all elements of T are row or column vectors, you can use VERTCAT or HORZCAT, using comma-separated list expansion:
T1 = {[1;2;3],[4],[5;6;7]} % all column vectors
V1 = vertcat(T1{:}) % single column
T2 = {[1 2 3],[4],[5 6 7]} % all row vectors
V2 = horzcat(T2{:}) % single row
For mixed types it will not work directly and you'll have to reshape them first
T3 = {[1;2;3],[4 5],[6 7]} % mixed type
T3c = cellfun(@(x) reshape(x,[],1), T3,'un',0) ; % convert to column vectors first
V3 = vertcat(T3c{:})

1 件のコメント

Sam sanati
Sam sanati 2015 年 5 月 3 日
Thanks for complete answer.

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

その他の回答 (1 件)

Jan
Jan 2015 年 5 月 3 日
編集済み: Jan 2015 年 5 月 3 日

0 投票

When the size of the elements of T are not matching, you can use: FEX: Cell2Vec

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

2015 年 5 月 3 日

編集済み:

Jan
2015 年 5 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by