how do I extract and plot data points from a 2D mesh?
12 views (last 30 days)
Show older comments
I have a 2D mesh, with x and y coordinates and the colour represents the temperature. I want to plot the temperature at 3 points on the mesh so that i can compare the temperature at those points to the temperature at the same points on a different mesh that i have. The figure shows the mesh that i want the temperatures extracted from from. Thank you!
2 Comments
Star Strider
on 6 Jan 2022
The image is an (8x1) patch array, and I had to dig through several layers of properites even to find that information.
I’m not even going to attempt to deal with that since I have no idea what any of it represents. Provide the arrays instead, along with code and extensive documentation.
Answers (1)
Pavan Sahith
on 16 Dec 2023
Hello Leah,
I understand that you are trying to extract the values at specific points from a 2D mesh and compare it with the values of your 2D mesh.
To extract values from a 2D mesh, you can consider using “interp2” as one of the methods.
The “interp2” function is used for 2D interpolation. It interpolates the values at the specified points based on the provided mesh. So, It might help you.
You can refer to this sample code to understand the usage of “interp2”.
% Generate 2D mesh
x = linspace(0, 1, 11);
y = linspace(0, 1, 11);
[X, Y] = meshgrid(x, y);
Z = sin(X.*Y);
% Extract points and compare values
points = [0.2 0.3; 0.4 0.5; 0.6 0.7];
values = interp2(X, Y, Z, points(:,1), points(:,2));
disp(values);
Similarly, you can extract the values from another 2D mesh and use for comparison.
Please refer to this MathWorks documentation to know more about
Hope this 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!