Creating Surface From Bounding Planes

5 次查看(过去 30 天)
Hello,
I have a 4d plot of points (NxNxNxN) for a given set of conditions. Calculating a set of points for each instance is computationally intensive. Is there a way for me to make a transparent hull while keeping the GPM color association of the outer surface? I tried convex hull but I didn't like the triangulated look of the mesh and couldn't figure out how to get the 4th dimension to display correctly.

采纳的回答

Neelanshu
Neelanshu 2024-1-29
Hi Alis,
I understand from your query that you are interested in plotting transparent hull of the 4d plot with the color association. You prefer to avoid using a convex hull due to the triangulated appearance of the mesh edges.
You can eliminate the triangular mesh edges by setting the "EdgeColor" property of "trisurf" to "none" and proceed with the convex hull. Additionally, you can set "FaceAlpha" to 0.5 to create a semi-transparent surface. Here is an example demonstrating how to set the surface color:
% Generate some example 3D data
num_points = 100; % Number of points
points = rand(num_points, 3) * 100; % Random points in a 100x100x100 cube
% Generate random GPM values between 50 and 200 for each point
gpm_values = 50 + (200-50) * rand(num_points, 1);
% Calculate the convex hull
[K, v] = convhull(points);
% Map GPM values to a colormap. Adjust the range [50, 200] if necessary.
gpm_colormap = gpm_values; % This will be used for color association
gpm_colormap(gpm_colormap < 50) = 50; % Thresholding values below 50 to 50
gpm_colormap(gpm_colormap > 200) = 200; % Thresholding values above 200 to 200
% Create a figure
figure;
% Plot the convex hull with GPM color association
trisurf(K, points(:,1), points(:,2), points(:,3), gpm_colormap, 'FaceAlpha', 0.5, 'EdgeColor', 'none');
% Set the colormap (you may choose a different colormap if you wish)
colormap(jet(256));
% Add a colorbar to the figure to show the GPM value association
colorbar;
caxis([50, 200]); % Set the color axis scaling to match the GPM range
% Label the axes for clarity
xlabel('X-axis');
ylabel('Y-axis');
zlabel('Z-axis');
title('Convex Hull with GPM Color Association');
You may refer to the following documentation to learn more about the "trisurf" function :
Hope this helps.
  1 个评论
ALis
ALis 2024-1-29
Perfect, exactly what I needed. Wasn't aware that I could remove the triangulation of trisurf. Thank you very much!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by