This question is closed. Reopen it to edit or answer.

Can someone help me? I am trying to print a 8-by-8 checkboard with red and black tiles

1 view (last 30 days)
Kevin Junior
Kevin Junior on 24 Sep 2013
Closed: MATLAB Answer Bot on 20 Aug 2021
I know that am gonna use two nested for loops.

Answers (2)

Walter Roberson
Walter Roberson on 24 Sep 2013
No "for" loop is needed. You can index with an increment of 2.

Image Analyst
Image Analyst on 24 Sep 2013
Edited: Image Analyst on 24 Sep 2013
Use the checkerboard() function in the Image Processing Toolbox:
cb = 255 * (checkerboard(20) > 0); % checkerboard.
blank = zeros(size(cb), 'uint8'); % Totally black image.
% Put checkboard into only the red channel of an RGB image.
rgbImage = cat(3,cb,blank,blank);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!