Cell array inside a cell array

I have a cell array
dataArray={[10x1 double] {10x1 cell} [10x1 double] [10x1 double]}
and I tried to obtain an output as follows:
test[dataArray{1:end-1}]
Error using horzcat
Dimensions of matrices being concatenated are not consistent.

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 10 月 5 日

0 投票

Your desired output is not at all clear.
temp = [num2cell(dataArray{1}), dataArray{2}, num2cell(horzcat(dataArray{3:end}))];
guess_at_your_desired_output = cell2mat(temp);
This requires that all of the cells within dataArray{2} have one row and the same number of columns.

4 件のコメント

Sérgio Querido
Sérgio Querido 2017 年 10 月 5 日
It's good but i have a new prob. I did a table but i need to remove quotes''. How can i do it??
Sérgio Querido
Sérgio Querido 2017 年 10 月 5 日
or other solution to transform Cell array.
Cedric
Cedric 2017 年 10 月 5 日
編集済み: Cedric 2017 年 10 月 6 日
If names do not contain single quotes:
dataArray{2} = strrep( dataArray{2}, '''', '' ) ;
Seeing Walter's comment below, I realize that I may have misunderstood. I thought that you had imported quoted names, not that it was an issue of display (?)
Walter Roberson
Walter Roberson 2017 年 10 月 5 日
In order to remove the quote marks, you would need to reformat the table as pure text.
Alternately, you would need to override the toolbox/matlab/datatypes/@tabular/disp.m routine to force tables to be displayed the way you want.
MATLAB table objects are objects for data storage, not objects for pretty display. They display as they do in order to emphasize the data types, just like character strings in cell arrays display the quotes too.

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

カテゴリ

ヘルプ センター および File ExchangeCell Arrays についてさらに検索

タグ

質問済み:

2017 年 10 月 5 日

編集済み:

2017 年 10 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by