Filter löschen
Filter löschen

how do I extract and plot data points from a 2D mesh?

5 Ansichten (letzte 30 Tage)
Leah Jones
Leah Jones am 6 Jan. 2022
Beantwortet: Pavan Sahith am 16 Dez. 2023
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 Kommentare
Star Strider
Star Strider am 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.
Leah Jones
Leah Jones am 6 Jan. 2022
This is the code to plot the figure that i have mentioned in the question;
%Read mesh from file
theMesh = readMesh('square8.txt'); %change mesh file to use a different mesh
%%%% FE SOLUTION
%Build Finite Element System
[A,B] = buildFE_1(theMesh);
%Solve System
U = A\B;
%%%% POST-PROCESSING
%Plot FEM solution on mesh
figure(1)
hold on
title('FE solution')
plotMesh(theMesh,U);
This is plotting a solution for the temperature of a block of lead using finite element analysis of linear triangular elements. I can provide the code for buildFE_1 if needed?
I know that in reality this would be a 3D problem but on the project that I am working on we are onlu considering it in 2D. The figure in particular is a simplified problem where there is a block of lead with a constant temperature of 70 at the top and 10 at the bottom, and assuming constant heat in the x direction to simplify it further. It is simplified as it is just to verify that the code buildFE_1 works as it should as i have used it to analyse the temperature within a lead pipe held by a steel flange. I can provide the code and figures for this too if needed.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Pavan Sahith
Pavan Sahith am 16 Dez. 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.

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by