octave

For loop to split matrix to equal sized sub-matrices

随声附和 提交于 2019-11-26 00:55:45
问题 Given a square matrix of say size 400x400 , how would I go about splitting this into constituent sub-matrices of 20x20 using a for-loop? I can\'t even think where to begin! I imagine I want something like : [x,y] = size(matrix) for i = 1:20:x for j = 1:20:y but I\'m unsure how I would proceed. Thoughts? 回答1: Well, I know that the poster explicitly asked for a for loop, and Jeff Mather's answer provided exactly that. But still I got curious whether it is possible to decompose a matrix into

For loop to split matrix to equal sized sub-matrices

ⅰ亾dé卋堺 提交于 2019-11-25 19:45:02
Given a square matrix of say size 400x400 , how would I go about splitting this into constituent sub-matrices of 20x20 using a for-loop? I can't even think where to begin! I imagine I want something like : [x,y] = size(matrix) for i = 1:20:x for j = 1:20:y but I'm unsure how I would proceed. Thoughts? Well, I know that the poster explicitly asked for a for loop, and Jeff Mather's answer provided exactly that. But still I got curious whether it is possible to decompose a matrix into tiles (sub-matrices) of a given size without a loop. In case someone else is curious, too, here's what I have