0

I'm using the Matlab checkerboard function to create a checkerboard. I'm interested in having the checkerboard as stripes (rather than checks) which I have figured out. I also want to change the colour of the stripes so that it's red and white or red and pink rather than black and white. I don't understand how to do this.

In the Matlab checkerboard function, black is defined as zeros(n) where n is the size and because the colour code for black in Matlab is [0 0 0], this works. But I don't get how to set this for it to produce red coloured tiles or stripes.

I have tried

   red = repmat([1 0 0], 81,27) 

to get red stripes for a checkerboard that I want with 81 squares. This produces an 81 x 81 matrix that looks like:

  1 0 0 1 0 0 1 0 0 .... 1 0 0 
  1 0 0 1 0 0 1 0 0 .... 1 0 0 
  1 0 0 1 0 0 1 0 0 .... 1 0 0 
  .
  .
  .
  1 0 0 1 0 0 1 0 0 .... 1 0 0 

And it isn't red, it's just black and white stripes of varying thickness.

Can anyone help?!

Maroun
  • 94,125
  • 30
  • 188
  • 241
Maheen Siddiqui
  • 539
  • 8
  • 19

1 Answers1

0

Use imagesc to plot, and colormap to change colors,

red = repmat([1 0 0], 81, 27);
cmap(1,:) = [1 0 0];
cmap(2,:) = [0 0 0];
imagesc(red);
colormap(cmap);

This should give you,

checkerboard with red stripes

kedarps
  • 851
  • 9
  • 19