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

2 visualizzazioni (ultimi 30 giorni)
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];

Risposte (1)

KSSV
KSSV il 3 Giu 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 Commenti
KSSV
KSSV il 3 Giu 2020
The how do you think strings and numbers will form a matrix? You need to save them either in table or cells.

Accedi per commentare.

Categorie

Scopri di più su Tables in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by