Borrar filtros
Borrar filtros

auto split matrix with text and numbers into other matrices (up to n)

1 visualización (últimos 30 días)
JL
JL el 3 de Jun. de 2020
Comentada: JL el 3 de Jun. de 2020
Matrix A
A = [Aaa Bbb Ccc 1 1 1
Ddd Eee Fee 1 1 1
Ggg Hhh Iii 1 1 2
Jjj Kkk Lll 1 1 2
Mmm Nnn Ooo 2 2 3
Ppp Qqq Rrr 2 2 3];
auto split into other matrices B,C,D (potentially all the way to N) based on the last column
B = [Aaa Bbb Ccc 1 1 1
Ddd Eee Fee 1 1 1];
C = [Ggg Hhh Iii 1 1 2
Jjj Kkk Lll 1 1 2];
D = [Mmm Nnn Ooo 2 2 3
Ppp Qqq Rrr 2 2 3];

Respuestas (1)

KSSV
KSSV el 3 de Jun. de 2020
C = A(:,end) ;
[c,ia,ib] = unique(C) ;
N = length(c) ;
iwant = cell(N,1) ;
for i = 1:N
iwant{i} = A(ib==i,:) ;
end
iwant
  6 comentarios
KSSV
KSSV el 3 de Jun. de 2020
The how do you think strings and numbers will form a matrix? You need to save them either in table or cells.

Iniciar sesión para comentar.

Categorías

Más información sobre Tables 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