Seperating array by row label

1 visualización (últimos 30 días)
Erin
Erin el 25 de Feb. de 2013
I have a cell array array that's of the from
name data data data data
.
.
.n rows
.
name data data data data
So something like
Apple 1 0 38 1 19 8.9
Carrot -1 4 8 4 3 10
Banana 9 3 1 -45 12 0
Banana 60 1 3 4 58 9
Apple 1 82 28 9 9 -1
Carrot 83 29 1 1 1 0
I'd like to seperate into seperate arrays (or maybe a 3D array), like:
Apple 1 0 38 1 19 8.9
Apple 1 82 28 9 9 -1
Carrot 83 29 1 1 1 0
Carrot -1 4 8 4 3 10
Banana 9 3 1 -45 12 0
Banana 60 1 3 4 58 9
Also, the number of different lables is not known.

Respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 25 de Feb. de 2013
Editada: Azzi Abdelmalek el 25 de Feb. de 2013
x = {'Apple' [ 1] [ 0] [38] [ 1] [19] '8.9'
'Carrot' [-1] [ 4] [ 8] [ 4] [ 3] [ 10]
'Banana' [ 9] [ 3] [ 1] [-45] [12] [ 0]
'Banana' [60] [ 1] [ 3] [ 4] [58] [ 9]
'Apple' [ 1] [82] [28] [ 9] [ 9] [ -1]
'Carrot' [83] [29] [ 1] [ 1] [ 1] [ 0]}
[a,b,c]=unique(x(:,1))
for k=1:numel(a)
y{k}=x(find(c==k),:)
end
y{:}

Categorías

Más información sobre Oceanography and Hydrology en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by