Dear All, I am solving a PDE in which I have to find the double integral of a discreet function. PDE has the following form:
where F(x,y) is a matrix of size (M,N), obtained by solving another PDE.
[F,x,y]=some_funtion_to_solve_PDE(some inputs);
I'll use some initial guess for G(x,y) within the integral which also gives me a matrix of the same size as F(x,y).
Here the integrand is a product of two discrete functions and the integral limits are numbers. Matlab built-in routine quad2d() requires the integrand to be a continuous function of x & y. Similarly, the other routines like integral2() also require continuous function expressions. I need help and suggestions on solving this double integral with discrete function, which will enable me to solve the PDE. Many Thanks.

 채택된 답변

Torsten
Torsten 2016년 8월 17일

2 개 추천

Take a look at the example "Multiple Numerical Integrations" under
Best wishes
Torsten.

댓글 수: 7

Raees
Raees 2016년 8월 18일
편집: Raees 2016년 8월 18일
@Torsten:
Thanks for your answer. I've used the following command:
x=0:0.1:2; %limits of integration for x
y=0:0.1:2; %limits of integration for y
I=trapz(y,trapz(x,F,2));
But it gives the following error,
LENGTH(X) must equal the length of Y in dim 2.
I cannot understand what I am doing wrong to evaluate this integral. If possible please help me to correct this code. Thanks.
Torsten
Torsten 2016년 8월 18일
You are aware that in your case, F must be a 21x21 matrix ?
Best wishes
Torsten.
Raees
Raees 2016년 8월 18일
@Torsten Thanks for reply.
I just used it as an example. F can be 41x41 matrix or 20x20 matrix. As you see in the original question, F comes from the solution of another PDE which i've solved earlier.
Thanks.
And does it work now with F being a 21x21 matrix ?
x=0:0.1:2;
y=0:0.1:2;
[X,Y] = meshgrid(x,y);
F = X.^2 + Y.^2;
I = trapz(y,trapz(x,F,2))
Note that F is 21x21.
Best wishes
Torsten.
Raees
Raees 2016년 8월 18일
What i understood from your above code, you wrote F to be a continous function. I cannot understand the reason of defining F = X.^2 + Y.^2?
In my problem, F is not a continuous function of x and y, in fact its a discrete data. F is a matrix [f_{i,j}] and each f_{i,j} is the value of F at some point (x,y). Hope I have conveyed you clearly my problem.
Thanks.
Torsten
Torsten 2016년 8월 18일
편집: Torsten 2016년 8월 18일
I just chose an analytical function form to create the matrix F for the sake of convenience.
F can be any matrix you like, as long as F has dimension
(length(y)) x (length(x))
Best wishes
Torsten.
Raees
Raees 2016년 8월 19일
Thanks, Torsten. This time, it worked. So nice of you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품

질문:

2016년 8월 17일

댓글:

2016년 8월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by