Error using cell2mat (line 52) CELL2MAT does not support cell arrays containing cell arrays or objects.

4 ビュー (過去 30 日間)
HI I have a cell array {4000x1 cell, 5000x1 cell} containing strings 'nameA', 'nameB' - I want to concatenate them into 1 long character array - cell2mat does the trick if the cells are numbers - but what do you use if you have strings as in my case? thanks
  2 件のコメント
Guillaume
Guillaume 2018 年 3 月 21 日
strings or char array?
Your notation would imply that you have 1x2 cell array, where each cell is itself a cell array (of size 4000x1 and 5000x1 respectively). Presumably each cell of these subcells are strings or char arrays?
Should each of the main two cell result in one char array (i.e one char array is the concatenation of the 4000 char array, and the other is the concatenation of 5000 char array), or should everything be concatenated together?
cgenes
cgenes 2018 年 3 月 21 日
please see my comment below to bird man
everything should be concatenated together
thanks

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

採用された回答

Birdman
Birdman 2018 年 3 月 21 日
vertcat(A{:})
  8 件のコメント
Stephen23
Stephen23 2018 年 3 月 21 日
編集済み: Stephen23 2018 年 3 月 21 日
@cgenes: In your question you stated that you have "I have a cell array {4000x1 cell, 5000x1 cell} containing strings 'nameA', 'nameB'", later you wrote "I have 24 character arrays", and now you write that you "have character arrays. a good example is 'load cities ' and the 'categories' character array". We still have no idea what you actually have, because your description changes every five minutes.
Note that the categories variable is actually a character array (not a cell of strings as you wrote in you question) and that this can easily be converted into one long character row vector, quite efficiently without any loop. Is that what you are trying to do?
cgenes
cgenes 2018 年 3 月 21 日
Hi all thanks for all your help -
in fact I had character arrays and I was using vertcat() - but it was somehow scrambling the arrays - and turning them all into numbers
anyway i've got a good hack now so works fine
thanks again

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by