Meshing a 2D contour plot
이전 댓글 표시
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
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
2020년 5월 14일
채택된 답변
추가 답변 (1개)
Jiexian Ma
2025년 4월 6일
0 개 추천
As far as I know, there are two ways to do this.
- Method 1. Create geometry through Constructive Solid Geometry and obtain mesh via PDE toolbox. darova's answer used this method.
- Method 2. Create geometry via polyshape and generate mesh via Im2mesh package.
Personally, I perfer method 2 because you can edit polyshape object easily.








You could check demo14 to demo17 in Im2mesh package. I provide a few examples.
카테고리
도움말 센터 및 File Exchange에서 Geometry and Mesh에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




