divide a matrix into small matrices

5 ビュー (過去 30 日間)
asaf omer
asaf omer 2021 年 4 月 10 日
編集済み: DGM 2021 年 4 月 10 日
hello everyone
by given a matrix ,for example 9x9 i wanna divide the matrix into 3x3 matrices and place new matrices instead them.
how can i do that?
thanks

採用された回答

DGM
DGM 2021 年 4 月 10 日
編集済み: DGM 2021 年 4 月 10 日
Something like this:
A=randi(89,9)+10 % make an example array
B=mat2cell(A,[3 3 3],[3 3 3]) % split the array into 9 arrays
B{1} % show one of the arrays
gives us this:
A =
22 77 67 99 12 97 48 19 37
26 17 61 85 50 16 69 91 79
16 41 99 32 85 31 93 15 12
44 55 15 48 81 13 37 91 34
75 38 18 43 94 22 97 21 93
45 70 96 81 28 71 80 42 85
14 82 47 13 87 13 18 31 13
11 71 71 81 33 86 26 60 96
69 93 47 14 16 36 27 62 46
B =
3×3 cell array
{3×3 double} {3×3 double} {3×3 double}
{3×3 double} {3×3 double} {3×3 double}
{3×3 double} {3×3 double} {3×3 double}
ans =
22 77 67
26 17 61
16 41 99

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by