I have a matrix [xy] of size [86 86]. I want to divide this matrix into 10 sub matrix. For thr last matrix there will be shortage of coordinates but can be padded with zeros.
[x y] = size(I)
nSub = 10;
B = mat2cell(I, 2*ones(size(I,1)/2,1), 2*ones(size(I,2)/2,1))
I tried using mat2cell function but the output didn't come well. Can any one tell me where am going wrong or can I change this function
Does this work for you?
I = rand(86,86);
[x y] = size(I)
nSub = 10;
%// padding
xp = x + nSub - mod(x,nSub);
yp = y + nSub - mod(y,nSub);
I(xp,yp) = 0;
%// submatrices
B = mat2cell(I, nSub*ones(xp/nSub,1),nSub*ones(yp/nSub,1))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.