1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Make a circle in square that is split 8x8 parts?

  1. Feb 22, 2016 #1
    • Member warned about posting with no effort and without the template
    Sorry if i may sound little unclear, english is not my first langue. I im looking for a way to create a circle that is in a square cut in 8x8 in matlab. I would be glad if someone could give me a hand.
  2. jcsd
  3. Feb 22, 2016 #2


    Staff: Mentor

    Welcome to PF!

    This looks like homework so you need to show us what you know and some code of what you've tried.

    Also a better description of the problem you are trying to solve.

    My initial thought was you are trying to draw a circle in a checkerboard (8x8 squares) but I think it may be more than that.
  4. Feb 22, 2016 #3
    Code (Matlab M):

    Np   = 400;         % Number of Particles
    t    = 10^3;        % Time
    M    = zeros(Np,2); % Predefined
    Msaf = zeros(Np,2); % Predefined
    modi = 0.1;         % Movement modification
    r    = 8;           % Radius
    rng('shuffle')      % More random

    % Circle
    cv = linspace(0,2*pi,100);
    cx = r*cos(cv);
    cy = r*sin(cv);
    %axis square
    % Circle

    for Pic=1:t
       if sqrt(Msaf(:,1).^2+Msaf(:,2).^2)<r

       %axis equal
       axis([-r r -r r]);
       grid on
       axis square

       hold on
       hold off

       if t==(100/t)*50
       if t==(100/t)*70
       if t==(100/t)*90
       if t==(100/t)*100
    <<Moderator's note: CODE tags added.>>
    Last edited by a moderator: Feb 22, 2016
  5. Feb 22, 2016 #4
    Yes i'm trying to draw a circle in a checkerboard (8x8 squares)
  6. Feb 22, 2016 #5


    Staff: Mentor

    And you need a formula like x^2 + y^2 = r^2 to plot in the 8x8 grid?
  7. Feb 23, 2016 #6
    ive figured it out now! Thanks for your help!
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted