Akzeptierte Antwort

Guillaume
Guillaume am 27 Apr. 2017
Bearbeitet: Guillaume am 28 Apr. 2017

1 Stimme

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

4 Kommentare

elisa ewin
elisa ewin am 27 Apr. 2017
Bearbeitet: elisa ewin am 27 Apr. 2017
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
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 am 28 Apr. 2017
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 am 9 Mai 2017
If I have semanticTrajCluster.cluster.locID (attached), how can I make the same thing?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by