Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Split one column data into 4 arrays
조회 수: 4 (최근 30일)
이전 댓글 표시
I have an array of 90872x1 double with 4 conditions. As follows:
A=
1
1
1
2
2
2
3
3
4
4
1
1
2
2
3
3
4
4
1
1
1
I want to split the vector into 4 arrays, one per condition. Each column of the new 4 arrays must contain de data of the conditions. Therefore.
A1=
1 1 1
1 1 1
1 1
A2=
2 2
2 2
2
A3=
3 3
3 3
A4=
4 4
4 4
Any help?
댓글 수: 3
Walter Roberson
2019년 4월 3일
That creates a cell array, but your question requires a numeric array as output.
답변 (1개)
KSSV
2019년 4월 3일
A=[1
1
1
2
2
2
3
3
4
4
1
1
2
2
3
3
4
4
1
1
1] ;
C = unique(A) ;
iwant = cell(length(C),1) ;
for i = 1:length(C)
iwant{i} = A(A==C(i)) ;
end
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!