Iterating using for loop on Images

Consider the following code for iterating through for loop in images by using matlab. In this example we are setting GREEN Channel of this image to 0 :

>> A = imread('DesertSmall.jpg'); % reading image
>> s = size(A) % image size (first height, second width, third channels)
>> figure
>> subplot(1,2,1),imshow(A); title('Original Image');
>> for i = 1 : s(1) % for height of image
     for j = 1 : s(2) % for width of image
       A(i,j,2) = 0; % A(<height>,<width>,<channel>), GREEN channel to 0;
     end
   end
>> subplot(1,2,2),imshow(A); title('Extracted Green Channel');

Output :