How can I divide a matrix by its columns ?

1 回表示 (過去 30 日間)
Andre
Andre 2014 年 4 月 23 日
編集済み: the cyclist 2014 年 4 月 23 日
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 Center および File ExchangeMultidimensional Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by