MATLAB: Mat2cell operation coordinates cell

operation cells

i have problem with cell operation. i have 2 cells, first cell is A. A has 8*8 blocks and every blocks has 8*8 pixel. the second cell is B, B has 13*13 blocks and every blocks has 8*8 pixel.
coordinates cell A (X1,Y1) and coordinates cell B (X2,Y2)
i want to process two cells to find e and f. e=X1-(0.5*X2) and f=Y1-(0.5.Y2). so finally the output, i have 169 value of e and f.

Best Answer

[X2, Y2, X1, Y1] = ndgrid(1:size(B,1), 1:size(B,2), 1:size(A,1), 1:size(A,2));
E = X1 - X2./2;
F = Y1 - Y2./2;
e = squeeze(mat2cell(E, size(B,1), size(B,2), ones(1,size(A,1)), ones(1,size(A,2))));
f = squeeze(mat2cell(F, size(B,1), size(B,2), ones(1,size(A,1)), ones(1,size(A,2))));