Subsetting a rectengular matrix

6 ビュー (過去 30 日間)
Raisul Islam
Raisul Islam 2018 年 7 月 8 日
コメント済み: Raisul Islam 2018 年 7 月 8 日
I am have a 5139 x 30 matrix.
I want to split this into 39 subsets.
How can I do this in a for loop condition in MATLAB? Think like this. First subset having 132 rows all columns. The second subset having 132+132 rows all columns, the third subset having 133+132+132 rows all columns. This will go on until 5139 rows is reached. This is how I need this actually.
Thank you.

採用された回答

Walter Roberson
Walter Roberson 2018 年 7 月 8 日
What you asked for will not fit. There is only enough data for each block to have 131, with 9 left over that could be distributed
N = 39;
R = size(YourMatrix,1);
pos = floor(linspace(1,R,N+1));
pos(end) = R+1;
sizes = diff(pos);
subsets = mat2cell(YourMatrix, sizes, size(YourMatrix,2));
  1 件のコメント
Raisul Islam
Raisul Islam 2018 年 7 月 8 日
Remarkable....thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by