如何将矩阵分成相等的部分? [英] How to divide a matrix into equals parts?

查看:30
本文介绍了如何将矩阵分成相等的部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个 100x100 的矩阵,我想将它分成 10x10 的相等部分.

Let's say I have a 100x100 matrix, I want to divide it into equal parts of 10x10.

问题是输入矩阵可以是任意大小(但总是模 10).我查看了 mat2cell 函数,但它似乎不适用于动态数量的零件.或者我错过了什么?

The problem is that the input matrix can be of any size (but always mod 10). I looked at the mat2cell function but it does not seem to work for a dynamic number of parts. Or am I missing something?

推荐答案

你只需要告诉 mat2cell 你希望矩阵如何划分.如果您确定它在两个方向上始终是 10 的倍数,那么它(相当)简单.假设 X 是您要划分的矩阵,并且您希望 Y 中的结果元胞数组:

You just have to tell mat2cell exactly how you want the matrix divided up. If you're positive that it is always going to be a multiple of 10 in both directions, then it is (fairly) simple. Assuming that X is the matrix that you want to divide, and you want the resulting cell array in Y:

Y = mat2cell(X, repmat(10,[1 size(X,1)/10]), repmat(10,[1 size(X,2)/10]));

这篇关于如何将矩阵分成相等的部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆