필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
JL
JL 2020년 6월 3일
댓글: JL 2020년 6월 3일
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];

답변 (1개)

KSSV
KSSV 2020년 6월 3일
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
KSSV
KSSV 2020년 6월 3일
The how do you think strings and numbers will form a matrix? You need to save them either in table or cells.
JL
JL 2020년 6월 3일
How do i do that, please?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by