Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

How to make a certain pattern on a 2-D grid

Asked by Aaron on 13 Sep 2013

I'm trying to code a black and white figure that is four quarter circles in a square grid. This is the image of what I want: https://docs.google.com/drawings/d/1FDyLv3zASGpJ3GCJ6r8ryEXfCbfaZN5fLGLTqLnKeSE/edit?usp=sharing. It will have a for statement and probably and if statement. The code below is not even close to what I want but illustrates the general setup.

    m = 51;
    n = 51;
    maxX = m;
    maxY = n;
    A = zeros(maxX, maxY);
    for i = (1:maxX)
      A(i:51,i:51) = 1;
      if A(i:51,i:51) == 1;
        A(26,i:51) = 0;
        A(i:51,26) = 0;
      end
    end
    imagesc(A');
    set(gca, 'YDir', 'normal');
    colormap(1-gray);
    axis equal;
    axis tight;

0 Comments

Aaron

Products

No products are associated with this question.

0 Answers

Contact us