This is my code. Please help me!
Thanks a lot!
tiles=zeros(500,500);
for m=1:(size(layerstacking_TOA_Ref,1)/500)-1
for n=1:(size(layerstacking_TOA_Ref,2)/500)-1
r=500*m;
c=500*n;
if m==1&&n==1
tiles(i,j)= layerstacking_TOA_Ref(1:r,1:c);
elseif m==1&&n~=1
tiles(i,j)= layerstacking_TOA_Ref(1:r,c+1:c+500);
elseif m~=1&&n==1
tiles(i,j)= layerstacking_TOA_Ref(r+1:r+500,1:c);
else
tiles(i,j)= layerstacking_TOA_Ref(r+1:r+500,c+1:c+500);
end
end
end
NDVI = zeros(size(tiles,1),size(tiles,2));
y = zeros(8);
for i=1:size(tiles,1)
for j=1:size(tiles,2)
for num1=1:16
for num2=1:16
for b=1:8 % bands of the image
y(b)= tiles{num1,num2}(i,j,b);
NDVI(i,j) = (y(5)-y(4))./ (y(5)+y(4));
end
end
end
end
end