Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Model a circle using finite difference equation in matlab

  1. Aug 24, 2014 #1
    hello. I have a matlab skeleton provided because i want to model a distribution with a circular geometry. all in all, i want the 3d graph of the code to be some type of cylinder. This is the code:

    % flat step condition
    for ii=1:nHi,
    for jj=1:nHj,
    if (X(ii)/R_P)<1 & (Y(ii)/R_P)<1,

    nHi is the maximum size of nodes in X direction and nHj is the maximum size in Y direction while R_P is the radius of the circle. I am struggling with this code because when I execute this, it only appears with a rectangular graph, instead of a circle-ish, when viewed from the top.

    what the code is trying to say is,
    if node is less than the diameter (x or y node),
    thickness is initial+step
    thickness is initial.

    Any tips will be greatly appreciated.
  2. jcsd
  3. Aug 24, 2014 #2
    Just a hunch, have you tried replacing this:

    if (X(ii)/R_P)<1 & (Y(ii)/R_P)<1

    with this?

    if ((X(ii) - Xm)^2 + (Y(ii) - Ym)^2 < R_P^2)

    where Xm and Ym are the coordinates of the center of the circle.
  4. Aug 25, 2014 #3
    Are you trying to embed a circle to a square domain or are you trying to make a circle domain? Why not do it in polar coordinates?
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Threads - Model circle using Date
Curveball Modeling Apr 4, 2015
DE for modelling motion of a box Feb 23, 2015
Modelling the motion of a meteor Dec 13, 2014
Modeling Rain Hitting Surface Apr 20, 2014
Differential equation of a circle Oct 22, 2012