Hi Jacopo,
I understand that you have a set of coordinate points representing the boundary of a region and an array indicating the shear stress values at these points. Further, you wish to visualize this data in MATLAB using color mapping to represent the magnitude at the respective points.
Here is how you can create a 3D surface plot with color mapping based on magnitude values-
- Create a 3D delaunay triangulation based on the input coordinates using the "delaunay" function.
- Normalize the shear stress magnitude values to the range [0, 1] for color mapping.
- Next, Create a 3D surface plot with color mapping based on the normalized magnitude values using the "trisurf" function.
- Finally, use a colormap and include a colorbar to represent the magnitude values.
The following code demonstrates the aforementioned method-
tri = delaunay(coordinates(:,1), coordinates(:,2), coordinates(:,3));
normalized_magnitude = (wssdata - min(wssdata)) / (max(wssdata) - min(wssdata));
trisurf(tri, coordinates(:,1), coordinates(:,2), coordinates(:,3), normalized_magnitude, 'FaceColor', 'interp', 'EdgeColor', 'none');
colorbar('Ticks', linspace(min(wssdata), max(wssdata), 5), 'TickLabels', arrayfun(@num2str, linspace(min(wssdata), max(wssdata), 5), 'UniformOutput', false));
title('3D Surface Plot with Color-Mapped Magnitude Values');
Further, refer to the following documentations to know more about the functions used in the above code -
- https://www.mathworks.com/help/matlab/ref/delaunay.html
- https://www.mathworks.com/help/matlab/ref/trisurf.html
- https://www.mathworks.com/help/matlab/ref/colorbar.html
Hope this helps you to understand to create a 3D surface plot with color mapping based on magnitude values.
Regards,
Vinayak Luha