Meshing a 2D contour plot

조회 수: 5 (최근 30일)
Elliot Bontoft
Elliot Bontoft 2020년 5월 14일
댓글: Elliot Bontoft 2020년 5월 20일
I am looking to create a mesh within the lines of a 2D contour plot.
For example, with the code:
f = peaks;
contour(f,[2 2])
You achieve the following plot:
I would like to be able to generate a mesh inside and outside of the contour lines (within a domain of say 50x50 for this example).
Could someone suggest the best way to achieve this?
Thank you in advance.
  댓글 수: 2
Ameer Hamza
Ameer Hamza 2020년 5월 14일
Are you trying to create a mesh plot? If you want to plot both inside and outside the contour lines, isn't it the same as a regular mesh plot? Can you show an example image of what is your intended output?
Elliot Bontoft
Elliot Bontoft 2020년 5월 14일
I am trying to develop a finite element mesh, both inside and outside the contour lines, where the nodes align on the contours themselves.
Something like:
but with the inside of the shape meshed too.
Where the shape would be defined by the contour lines from the contour(f,[2 2]) function.
Thanks

댓글을 달려면 로그인하십시오.

채택된 답변

darova
darova 2020년 5월 14일
Use initmesh
clc,clear
x1 = [0 5 5 0]; % rectangle
y1 = [0 0 3 3];
[x2,y2] = pol2cart(0:.3:2*pi,1); % circle
gd2 = [2;length(x2);x2(:)+1.5;y2(:)+1.5]; % circle geometry
gd1 = gd2*0;
gd11 = [2;length(x1);x1(:);y1(:)]; % rectangle geometry
gd1(1:length(gd11)) = gd11;
dl = decsg([gd1 gd2],'P1-P2',char('P1','P2')'); % decomposition geometry
[p,e,t] = initmesh(dl); % build a mesh
pdemesh(p,e,t) % display mesh
dl2 = decsg(gd2); % decomposition of circle
[p,e,t] = initmesh(dl2); % build a mesh
hold on
pdemesh(p,e,t) % display emsh
hold off
  댓글 수: 4
darova
darova 2020년 5월 19일
Can be connected closer
Elliot Bontoft
Elliot Bontoft 2020년 5월 20일
Hi Darova,
I see what you've done there, very clever work around. However, I will be using this meshed model to run a simulation on, and the boundaries will influence the behaviour of the response.
Thank you for the suggestions

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by