- Define the Exclusion Zone: Determine the mathematical representation of your exclusion zone (e.g., for a cylinder, use its center coordinates and radius).
- Filter Out Points Within the Exclusion Zone: For each point in your dataset, check if it falls within the exclusion zone (e.g., for a cylinder, check if a point is within the cylinder's radius). Exclude these points from your dataset
Make a mask and apply it to other matlab figures
4 views (last 30 days)
Show older comments
Hi everyone,
I have an ensamble of point and for each of them a value (x,y,value). I need to make a contour plot whit this data. I resolved the problem in two different ways: (1) the scatter function and (2) the delaunayTriangulation with trisurf functions. These two figures are the results. These pictures represent a flow over a cylinder. The problem is that I'd like to use the second solution in order to have a better contour, but I need the cylinder zone also. The trisurf function works with an interpolation that make contour appears also in the cylinder zone. I need a solution that I can apply also to more complex geometry. Make a mask by selecting points from the figure is not very user-friendly. Someone can help me? 

0 Comments
Answers (1)
Hornett
on 24 May 2024
To exclude a specific zone like a cylinder from your contour plot while using trisurf in MATLAB, follow these steps:
% Assuming cx, cy, r represent the cylinder's center and radius
insideCylinderIdx = (x - cx).^2 + (y - cy).^2 <= r^2;
xFiltered = x(~insideCylinderIdx);
yFiltered = y(~insideCylinderIdx);
valuesFiltered = values(~insideCylinderIdx);
3.Perform Delaunay Triangulation on Filtered Data: Use the filtered dataset (points outside the exclusion zone) to perform Delaunay triangulation.
tri = delaunay(xFiltered, yFiltered);
4. Plot Using trisurf: Use the trisurf function to create a surface plot from the triangulated data.
trisurf(tri, xFiltered, yFiltered, valuesFiltered);
This approach allows you to create contour plots that exclude specific zones, such as a cylinder, and can be adapted to more complex geometries by appropriately defining and filtering out the exclusion zones before triangulation and plotting.
You can reffer to following documention for more details : https://www.mathworks.com/help/matlab/ref/trisurf.html
I hope it helps
0 Comments
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!