split Matrix into small matrices...

11 ビュー (過去 30 日間)
Aniya
Aniya 2016 年 10 月 25 日
回答済み: Walter Roberson 2016 年 10 月 25 日
I want to split 1-by-120 matrix into 12 1-by-10 Matrices.Please help me?Thank you for your help.

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 10 月 25 日
general form:
cols = size(YourMatrix, 2);
rows = size(YourMatrix, 1);
rows_at_a_time = rows;
cols_at_a_time = 10;
row_split = [rows_at_a_time * ones(1, floor(rows/rows_at_a_time)), mod(rows, rows_at_a_time)] ;
cols_split = [cols_at_a_time * ones(1, floor(cols/cols_at_a_time)), mod(cols, cols_at_a_time)] ;
result = mat2cell(YourMatrix, row_split, cols_split) ;
Or in the particular case where you know for sure that the size is 1 x 120 to be broken up into 10s
result = mat2cell( YourMatrix, 1, 10 * ones(1, 12));

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by