如何按要求将大矩阵分割成小矩阵。

14 ビュー (過去 30 日間)
niginok
niginok 2022 年 11 月 24 日
回答済み: rikimiw 2022 年 11 月 24 日
有一个m*m的大矩阵A,如果m1+m2+...+mn=m,如何实现按照[m1 m2 ... mn]划分大矩阵A呢?
例如矩阵:
1 2 3
4 5 6
7 8 9
如果按照[1 2]划分,我想得到
[1] [2 3] [4;7] [5 6; 8 9]
有什么好点的方便点的方法吗,最好不用循环,谢谢!

採用された回答

rikimiw
rikimiw 2022 年 11 月 24 日
clear
clc
Mat = [1:4;5:8;9:12;13:16]
dim = [1 2 1];
Out = mat2cell(Mat,dim,dim)

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange编程 についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!