auto split matrix into other matrices (up to n)

2 Ansichten (letzte 30 Tage)
JL
JL am 28 Mai 2020
Kommentiert: JL am 28 Mai 2020
Matrix A
A = [1 55 14 1 1 1
2 55 14 1 1 1
5 35 13 1 1 2
6 35 12 1 1 2
7 35 11 2 2 3
8 35 11 2 2 3;
auto split into other matrices B,C,D (potentially all the way to N) based on the last column
B = [1 55 14 1 1 1
2 55 14 1 1 1];
C = [5 35 13 1 1 2
6 35 12 1 1 2];
D = [7 35 11 2 2 3
8 35 11 2 2 3];

Akzeptierte Antwort

KSSV
KSSV am 28 Mai 2020
A = [1 55 14 1 1 1
2 55 14 1 1 1
5 35 13 1 1 2
6 35 12 1 1 2
7 35 11 2 2 3
8 35 11 2 2 3];
C = A(:,end) ;
[c,ia,ib] = unique(A(:,end)) ;
N = length(c) ;
iwant = cell(N,1) ;
for i = 1:N
iwant{i} = A(ib==i,:) ;
end
  3 Kommentare
KSSV
KSSV am 28 Mai 2020
You have what you want....iwant{1}, iwant{2}, iwant{3}
JL
JL am 28 Mai 2020
thats true! thanks :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Smoothing finden Sie in Help 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