Crop an Image without built-in function| MATLAB

Code:

function z = crop_image(x, rmin, cmin, rpix, cpix)
  z=[];
temp=1;
gemp=1;
for i=rmin:(rmin+rpix-1)
    for j=cmin:(cmin+cpix-1)
        z(temp,gemp)=x(i,j);
        gemp=gemp+1;
    end
    temp=temp+1;
    gemp=1;
end
end

No comments