필터 지우기
필터 지우기

Double integration with trapz

조회 수: 1 (최근 30일)
Habib
Habib 2014년 10월 2일
댓글: Habib 2014년 10월 2일
Hi everyone! I'm new in matlab,and I'd like using from trapz for solve this equation: exp(r1.*r2)over on the r1 and r2; but I couldn't, for solve this double integration, I expanded exp(r1.*r2) and got the solution but because of I am trying to simulation a laser cavity, that solution is not more exact. so I am hope solve this double integral and I need help. please help me. N=256; a=10e-6; r1=-N/2*a:a:(N/2-1)*a; r2=r1; [R1 R2]=meshgrid(r1,r2)

답변 (1개)

Jeremy Kemmerer
Jeremy Kemmerer 2014년 10월 2일
It sounds like you are trying to perform numerical double integration. Have you tried using the function “integral2”?
Here’s how you might do that for your example:
>>fun = @(x,y) exp(x.*y); //handle to function to be integrated
>>llim = -N/2*a; //define limits of integration
>>ulim = (N/2-1)*a;
>>q = integral2(fun,llim,ulim,llim,ulim);
Please refer to the following documentation for more information about the “integral2” function: http://www.mathworks.com/help/matlab/ref/integral2.html
  댓글 수: 1
Habib
Habib 2014년 10월 2일
thank you for your reply. I want use from trapz command because its solutions are more exact than the solutions of integral2 command. so how can I do it with trapz command?

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

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by