Integrating Trisurf for 3D Mesh Comparison in Domain D

  • Context: MATLAB 
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Integrating
Click For Summary
SUMMARY

This discussion focuses on integrating 3D meshes using the MATLAB function trisurf to compute the double integral of the squared difference between two surfaces, defined over the domain D = [0,2]×[0,2]. The integration process utilizes the trapz function for numerical integration, first along the rows and then along the columns of the matrix representing the integrand. A practical example demonstrates this method, yielding an expected integral result of 4, confirming the approach's validity. Additionally, it is suggested to interpolate coarse data for improved accuracy in surface representation.

PREREQUISITES
  • Familiarity with MATLAB programming
  • Understanding of numerical integration techniques
  • Knowledge of 3D mesh generation using trisurf
  • Basic concepts of matrix operations in MATLAB
NEXT STEPS
  • Explore MATLAB's interp2 function for surface interpolation
  • Learn about advanced numerical integration methods in MATLAB
  • Investigate the meshgrid function for creating 2D grids
  • Study the application of trapz in higher dimensions
USEFUL FOR

This discussion is beneficial for MATLAB users, data scientists, and engineers involved in 3D modeling and numerical analysis, particularly those looking to compare surfaces and perform numerical integrations effectively.

member 428835
Hi PF!

I have a 3D mesh generated via the trisurf function, where they each have different node numbers, but are both defined over the same domain ##D##. See attachments for clear image.

If the surfaces are ##f1## and ##f2##, I'd like to compute ##\iint_D(f1-f2)^2## where ##D = [0,2]\times[0,2]## . Any idea how?
 

Attachments

Physics news on Phys.org
Here is an example on how to do a double numerical integration:
http://www.mathworks.com/help/matlab/ref/trapz.html#buakefe-1_1

The idea is that you express the integrand as a matrix of values, then call trapz the first time operating on the rows, then take that result and integrate a second time operating on the columns. It looks something like this:

Code:
dx = 0.1;
dy = 0.1;
x = 0:dx:2;
y = 0:dy:2;
[X,Y] = meshgrid(x,y);   % create mesh
f1 = X.^2 + Y.^2;        % first surface defined on the mesh of (x,y) points
f2 = X.^2 + Y.^2 + 1;    % second surface
f = (f1 - f2).^2;        % integrand
Q = trapz(x,f,2);        % integrate wrt X
I = trapz(y,Q)           % integrate the result wrt Y

In this simple example you have the same surface separated vertically by 1 unit, so since the domain is a 2x2 square, you expect the integral to reproduce the volume of a 2x2x1 cube, which acts as a nice sanity check for the code above:

Code:
I =

    4

If the data you have for the surfaces is coarse, you can interpolate to define the surface on a finer mesh, then integrate the new surface.
 
Last edited:

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
6K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 73 ·
3
Replies
73
Views
8K