フィルターのクリア

How to effectively concatenate values in cells with different dimension into single column double

1 回表示 (過去 30 日間)
Dear Coder,
I have cells with diffrent dimension, for example cell {1}=[1 2 3], cell {2}=[ 4 5 6 7 8] cell{3}=[9 10]. How can I concatenate the value within each cell into a single row, such that, row_doub=[1 2 3 4 5 6 7 8 9 10]. Any suggestion is greatly appreciate.

採用された回答

OCDER
OCDER 2017 年 9 月 29 日
C{1} = [1 2 3];
C{2} = [4 5 6 7 8];
C{3} = [9 10];
D = cat(2, C{:});
D =
1 2 3 4 5 6 7 8 9 10
  2 件のコメント
balandong
balandong 2017 年 9 月 29 日
Hi Donald,
I really appreciate for the reply! Your suggestion work like a charm
OCDER
OCDER 2017 年 9 月 29 日
You're Welcome! If you want to learn more about how this works, here's a link for using comma-separated lists - quite a neat trick in Matlab
For instance, this also works:
D = [C{:}]

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by