ImageAnalyst <email@example.com> wrote in message <firstname.lastname@example.org>... > I'd probably make one colored square and one white (or black) square > stitched together. Then use repmat() to replicate that pair to > complete the checkerboard.
Thanks. I did manage to figure this out soon after posting my question, though I'm still not sure I'm doing it as efficiently as possible. Despite what I originally said, I have decided it is simpler to index into the colormap.
I have d colours, not one and not two. My procedure is to stitch together d squares, each kxk and each with its own colour, in a column. This is now a d*k by k matrix. Using circshift(columnAlreadyConstructed,k) and stitching, I get a d*k x 2*k matrix. Applying circshift(matrixAlreadyConstructed, 2*k), I get a d*k x 4*k matrix. Continue like this until 2 to the appropriate power is greater than d. Cut the matrix down to a d*k by d*k matrix. Then use repmat to fill out the matrix completely. This actually gives a matrix that will be bigger than the original MxN asked for, but one can just take the first M rows and N columns.
That's the best I can do for now. I was missing circshift when I posted my question. I need to make these chequerboards as quickly as possible, because my code uses the operation quite often.