Implementing a numerical integration expression

1 view (last 30 days)
Hi All
I am struggling to implement the following expression in Matlab. The expression seems fairly straight forward, but I just can't get it to run. Any help would be appreciated.
Thanks.

Answers (1)

Roger Stafford
Roger Stafford on 8 Sep 2014
Edited: Roger Stafford on 8 Sep 2014
Use matlab's 'integral2' function. It provides for inner integration limits to be functions of the outer variable of integration, which is what you have. Your limits, beta*r1 and beta*r2, depend on beta, the outer variable of integration.
  2 Comments
Wayne
Wayne on 8 Sep 2014
Thank for the response. Previously, I had done what you said in a similar way. Using that approach I had managed to get a solution, but when I try to modify the 1/beta^3 term to a different case of interest, i.e. 1/beta^5, a different problem arises. The result goes from a numerical value to NaN. See attached.
%WORKS clear all
r1=1; r2=2;
fun1 = @(x) x.*besselj(1,x)
fun2 = @(beta) (beta.^-3).*integral(fun1,beta.*r1,beta.*r2,'ArrayValued',true)
Z = integral(fun2,0,5,'ArrayValued',true)
%DOES NOT WORK clear all
r1=1; r2=2;
fun1 = @(x) x.*besselj(1,x)
fun2 = @(beta) (beta.^-4).*integral(fun1,beta.*r1,beta.*r2,'ArrayValued',true)
Z = integral(fun2,0,5,'ArrayValued',true) if true % code end
Roger Stafford
Roger Stafford on 8 Sep 2014
My advice was to call on 'integral2', not 'integral'. It is specially designed for double integrals, which is what you are dealing with. Read its documentation carefully before trying to use it:
http://www.mathworks.com/help/matlab/ref/integral2.html

Sign in to comment.

Categories

Find more on Programming 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!