Check out example codes for "matlab create image". It will help you in understanding the concepts better.

Code Example 1

% Define A as your size matrix, this example uses 200x200 of 0's
A = uint8(zeros(200,200));

% loop over M x N with two for's
for row 1:size(A,1)
	for col 1:size(A,2)
    	% your logic here, example:
        A(row,col) = 255
	end
end

% image matrix is now 200x200 of 255, using imshow will display a white image.
% imshow(A)

Learn ReactJs, React Native from akashmittal.com