Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
813 views
in Technique[技术] by (71.8m points)

matlab - How to divide a matrix into equals parts?

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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]));


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...