Info

この質問は閉じられています。 編集または回答するには再度開いてください。

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

1 回表示 (過去 30 日間)
Kevin Junior
Kevin Junior 2013 年 9 月 24 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I know that am gonna use two nested for loops.

回答 (2 件)

Walter Roberson
Walter Roberson 2013 年 9 月 24 日
No "for" loop is needed. You can index with an increment of 2.
  2 件のコメント
Kevin Junior
Kevin Junior 2013 年 9 月 24 日
I am kinda new to MATLAB could you be more specific?
Walter Roberson
Walter Roberson 2013 年 9 月 24 日
What do you get if you use
A = zeros(5,5);
A(1:2:end,:) = 1;

Image Analyst
Image Analyst 2013 年 9 月 24 日
編集済み: Image Analyst 2013 年 9 月 24 日
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);
imshow(rgbImage)

Community Treasure Hunt

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

Start Hunting!

Translated by