MATLAB Answers

I want to mesh a square element with a circular hole in the middle

27 ビュー (過去 30 日間)
Rawaha Nakhuda
Rawaha Nakhuda 2019 年 3 月 24 日
コメント済み: John D'Errico 2020 年 1 月 23 日
I want to discretize a unit square with a circulae hole in the middle, something similar to the picture below:
I'm having problems using the mesh function to actually create something like this. The mesh I need to create should be changable, like large meshes or small meshes for different results. Any help in creating this structure for my code would be greatly appreciated!

  0 件のコメント

サインイン to comment.

回答 (1 件)

John D'Errico
John D'Errico 2019 年 3 月 24 日
編集済み: John D'Errico 2019 年 3 月 24 日
Use polar coordinates.
Surely you know the equation of a circle in polar coordinates.
r = r0
What is the equation of a unit square in polar form? I think this trick may be less commonly known.
r = min(1/abs(sin(theta)), 1/abs(cos(theta)))
Scale it up for a non-unit square. So just take a linear combination of the two, at any value for theta. That will give you your mesh. Do I need to write it out?
theta = linspace(0,2*pi,17);
u = linspace(0,1,5)';
r0 = 0.5;
R = r0.*u + (1-u).*min(1./abs(sin(theta)), 1./abs(cos(theta)));
X = R.*cos(theta);
Y = R.*sin(theta);
And, yes, the above code will require at least R2016b to run properly. Still fixable using an older release via bsxfun, but much cleaner this way.
(My use of plot to create the meshed grid there was kind of cute, I think.)

  3 件のコメント

Rawaha Nakhuda
Rawaha Nakhuda 2019 年 3 月 25 日
Thanks for the help, I just have a question,
All the small meshes in the figure represent truss elements and I wish to use each of them seperately. I have found a way to generate a list of the coordinates in a nx2 matrix. But I also wish to create an element list where each small line is represented by the adjoining coordinates. For example, I have a point in the middle which is the first row of my nx2 matrix, so it is given number 1, and the rest of the coordinates are given subsequent numbers. I wish to show each line as an element list and which numbered coordinates is it connected with. I hope it's not too confusing and you can help me in this regard.
Thank you so much for the help though, really appreciate it!
Hukum Dewangan
Hukum Dewangan 2020 年 1 月 23 日
Can you help me to plot surface using the same meshgrid? As of now, I could not get the hole in the final surface plot.
John D'Errico
John D'Errico 2020 年 1 月 23 日
@Hukum Dewangan - that is a different problem, but still not difficult. If you have a problem, ask the questoin separately. Otherwise, this turns into an extended consulting session in the comments, leading to all sorts of followup questions, and I will not participate in that.
If you do ask a question, then show what you tried, explain why you think it failed for you.

サインイン to comment.

サインイン してこの質問に回答します。




Translated by