Info
此问题已关闭。 请重新打开它进行编辑或回答。
Split one column data into 4 arrays
1 次查看(过去 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!