Plotting Free Surface Using MATLAB | Get Results Quickly

  • Context: MATLAB 
  • Thread starter Thread starter hunt_mat
  • Start date Start date
  • Tags Tags
    Matlab Plotting
Click For Summary
SUMMARY

This discussion focuses on plotting a free surface using MATLAB by evaluating a complex double integral. The integral is defined by a specific mathematical expression involving parameters such as U, B, and E_b, with the integrand requiring careful handling to avoid zeros in the denominator. The user has implemented a trapezium rule for numerical integration but seeks a more efficient method to compute the integral accurately. The provided MATLAB code demonstrates the trapezium rule's application, which has been tested successfully with a Gaussian function.

PREREQUISITES
  • Understanding of double integrals and numerical integration techniques.
  • Familiarity with MATLAB programming and syntax.
  • Knowledge of Fourier transforms, particularly 2D Fourier transforms.
  • Basic understanding of hyperbolic functions and their applications in integrals.
NEXT STEPS
  • Explore MATLAB's built-in functions for numerical integration, such as integral2.
  • Learn about advanced numerical methods for double integrals, including Monte Carlo integration.
  • Investigate the implications of singularities in integrands and techniques to handle them.
  • Study the application of Fourier transforms in solving partial differential equations.
USEFUL FOR

Researchers, engineers, and students in fields such as applied mathematics, computational physics, and engineering who are working on numerical methods for integrals and surface plotting in MATLAB.

hunt_mat
Homework Helper
Messages
1,816
Reaction score
33
Hi,

I like to think that I can generally get MATLAB to do what I want and when I want but this has got me stumped. I want to plot a free surface defined by a double integral:
[tex] \eta =\frac{1}{4\pi^{2}}\int_{\mathbb{R}^{2}}\frac{\mu e^{-\mu^{2}/4}e^{i(kx+ly)}\tanh\mu}{U^{2}k^{2}-\mu (B-E_{b}\mu+\mu^{2})\tanh\mu}dkdl[/tex]
Where [itex]\mu=\sqrt{k^{2}+l^{2}}[/itex]. I wrote a routine that does a double integral trapezium rule reasonably well but I need to get it working for the integrand above. Is there a quick method I can use to do this?

I should add that U is chosen such that the denominator has no zeros.
 
Physics news on Phys.org
I should add, the algorithm I used to compute the 2D trapezium rule is
[tex] \begin{array}{rcl}<br /> \int_{a}^{b}\int_{c}^{d}f(x,y)dxdy & = & \left(\sum_{i=1}^{N}\sum_{j=1}^{M}f(x_{i},y_{j})-\frac{1}{2}\sum_{i=1}^{N}f(x_{i},c)-\frac{1}{2}\sum_{i=1}^{N}f(x_{i},d)\right)\delta x\delta y \\<br /> & - & \left(\frac{1}{2}\sum_{j=1}^{M}f(a,y_{j})+\frac{1}{2}\sum_{j=1}^{M}f(b,y_{j})\right)\delta x\delta y -{} \\<br /> & - & \frac{1}{4}(f(a,c)+f(a,d)+f(b,c)+f(b,d))\delta x\delta y<br /> \end{array}[/tex]
The piece of Matlab code I used to compute the integral is given in here. I tested it out by computing the inverve 2D Fourier transform of a Gaussian and that seemed to work fine.
function y=trap_2d(A,dx,dy)
N=length(A(:,1));
M=length(A(1,:));

a=A(1,1)+A(1,M)+A(N,1)+A(N,M);
b=sum(A(1,:))+sum(A(N,:));
c=sum(A(:,1))+sum(A(:,M));
u=zeros(1,N);
for i=1:N
u(i)=sum(A(i,:));
end

d=sum(u);

y=(d-0.5*c-0.5*b-0.25*a)*dx*dy;
 

Similar threads

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