MATLAB: How to make nested loop from 8×8 block for image size 512×512

for loopnested for loop

i have an image with size 512×512, then i make a 8×8 block so there is 4096 block, i want to calculate variance function in each block, how to make a for loop kx so one block kx will calculate and move again in second block then calculate again so it will calculate all 4096 block, i'm stuck just only one row inside of first block, can someone help me? thank u
i []; j[];
for k=1:4096
kx=(x{k});% extracting block into kx for processing
for i = 1:8
for j = 1:8
Variance = var(kx);
end
end
end