Model a circle using finite difference equation in matlab

Click For Summary
SUMMARY

The forum discussion focuses on modeling a circular geometry using finite difference equations in MATLAB. The provided code attempts to create a cylindrical 3D graph but results in a rectangular shape instead. A suggested modification to the conditional statement is to replace the existing check with a circular equation that uses the center coordinates (Xm, Ym) and the radius (R_P) to accurately represent the circle. Additionally, the discussion raises the possibility of using polar coordinates for better representation.

PREREQUISITES
  • Understanding of MATLAB programming and syntax
  • Familiarity with finite difference methods
  • Knowledge of 3D graphing techniques in MATLAB
  • Basic concepts of polar coordinates
NEXT STEPS
  • Implement the suggested conditional modification in MATLAB to model the circle accurately
  • Explore MATLAB's polar coordinate functions for circular geometry representation
  • Research finite difference methods for 3D modeling
  • Learn about visualizing cylindrical shapes in MATLAB
USEFUL FOR

Mathematics and engineering students, MATLAB programmers, and anyone interested in computational modeling of geometric shapes.

tomallan
Messages
20
Reaction score
0
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,
h(ii,jj)=h_init+h_step;
else,
h(ii,jj)=h_init;
end
end
end

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
else,
thickness is initial.

Any tips will be greatly appreciated.
 
Physics news on Phys.org
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.
 
  • Like
Likes   Reactions: 1 person
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?
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K