採用された回答

Guillaume
Guillaume 2017 年 4 月 27 日
編集済み: Guillaume 2017 年 4 月 28 日

1 投票

Are you looking for
{L1.l} %for row vector of cells
or something more complex?

4 件のコメント

elisa ewin
elisa ewin 2017 年 4 月 27 日
編集済み: elisa ewin 2017 年 4 月 27 日
vertcat don't run
'Error using vertcat
Dimensions of matrices being concatenated are not
consistent'
I want something more complex: I want that the struct became a matrix that have all the values in the field l; use {L1.l} gives a vector but I want have a matrix of cells like this:
A={'1' '142' '174' '168' '133' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '';'1' '142' '1' '133' '154' '167' '174' '142' '1' '131' '142' '1' '142' '' '' '' '' '' '' '' '' '';'174' '142' '1' '167' '1' '131' '142' '1' '131' '1' '131' '1' '142' '176' '150' '1' '' '' '' '' '' '';'174' '1' '137' '142' '133' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ''; continue with all the values in the struct}
I hope it's clear
Guillaume
Guillaume 2017 年 4 月 28 日
I shouldn't have edited my post to add the vertcat. Of course it wouldn't work.
However, it would have produced the exact result you wanted if all the cell arrays had the same number of columns. So the key to do what you want is to make all these cell arrays the same size before vertically concatenating them (assuming that's acceptable):
maxcols = max(arrayfun(@(l1) size(l1.l, 2), L1));
resizedcells = cellfun(@(c) [c, repmat({''}, size(c, 1), maxcols - size(c, 2))], {L1.l}, 'UniformOutput', false);
concatenatedcells = vertcat(resizedcells{:})
Stephen23
Stephen23 2017 年 4 月 28 日
Why is this data not stored in a cell array in the first place? There is only one field in the structure, which totally defeats the purpose of using a structure.
elisa ewin
elisa ewin 2017 年 5 月 9 日
If I have semanticTrajCluster.cluster.locID (attached), how can I make the same thing?

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Structures についてさらに検索

タグ

質問済み:

2017 年 4 月 27 日

コメント済み:

2017 年 5 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by