How can I divide a matrix by its columns ?

1 次查看(过去 30 天)
Hi,
for example:
[ 1 35 37 29 312
1 321 421 2 34
1 329 412 32 54
.
.
.
4 421 348 48 445
4 48 49 41 394 ]
Can I segregate this matrix in small matrix based on the first column ?
Example:
A = [ 1 35 37 29 312
1 321 421 2 34
1 329 412 32 54]
B =...
C =...
D = [ 4 421 348 48 445
4 48 49 41 394 ]
Andre

采纳的回答

the cyclist
the cyclist 2014-4-23
编辑:the cyclist 2014-4-23
Yes, use the accepted answer from Azzi that is posted here. Just choose the 1st column instead of the 4th column.
Namely, if your original matrix is called A, then
[ii,jj,kk] = unique(A(:,1))
out = accumarray(kk,1:numel(kk),[],@(x) {A(x,:)})
celldisp(out)
You will see that "out" is a cell array, where each cell has one of the smaller matrices you want.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by