Creating Surface From Bounding Planes
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
2 commentaires
Réponse acceptée
nick
le 29 Jan 2024
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!