Extract the longest edge of a mesh generated by pdetool

4 views (last 30 days)
When I generate a mesh with pdetoolbox, like the one in the image. How can I extract the norm (longest edge value) of the mesh? I have been looking for a while, but couldn't find anything helpful.

Accepted Answer

Alan Weiss
Alan Weiss on 16 Jul 2018
Edited: Alan Weiss on 16 Jul 2018
You can extract the information yourself from the Mesh Data.
First, export your mesh (I assume that it is a linear mesh) from Mesh > Export Mesh. You get p, e, and t matrices in your workspace.
Then find the lengths of all the triangles in your mesh.
edge1 = p(:,t(1,:)) - p(:,t(2,:)); % point 1 to point 2
edge2 = p(:,t(1,:)) - p(:,t(3,:)); % point 1 to point 3
edge3 = p(:,t(2,:)) - p(:,t(3,:)); % point 2 to point 3
L1 = hypot(edge1(1,:),edge1(2,:)); % Find the lengths
L2 = hypot(edge2(1,:),edge2(2,:));
L3 = hypot(edge3(1,:),edge3(2,:));
Then find the longest of the lengths.
[long1,idx1] = max(L1)
[long2,idx2] = max(L2)
[long3,idx3] = max(L3)
There may be more efficient ways to code this, but I just tried the code I gave and believe that it works.
Alan Weiss
MATLAB mathematical toolbox documentation

More Answers (0)

Categories

Find more on Partial Differential Equation Toolbox 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!