how to use quadl function to integrate a function of combination Bessel function and a vector
Show older comments
Hello, I tried to use quadl command to build up a function of Bessel function multiply with a vector and integrate it from 0 to 1. My coding is below:
u=0.:0.01:1.0; nu=1.5; u=u.^1.5;
w=@(u) u.*besselj(nu,u);
quadl(w, 0, 1)
and it turns out as "identifier" expected, "(" found.
and then I modify my code using inline command and hope to create a function. the coding is below:
u=0.:0.01:1.0; nu=1.5; z=u.^1.5;
g=inline('besselj(nu,u).*z','u','nu','z');
quadl(g, 0, 1)
and it turns out as
Error using ==> inline/feval
Not enough inputs to inline function.
Could someone please to help me? Your prompt answer will be deeply appreciated. BR Donyau
1 Comment
Donyau Chiang
on 13 May 2016
Accepted Answer
More Answers (1)
Star Strider
on 13 May 2016
You’re integrating an array-valued funciton, so you need to use the quadv funciton:
u=0.:0.01:1.0; nu=1.5; u=u.^1.5;
w=@(u) u.*besselj(nu,u);
int_w = quadv(w, 0, 1);
If you have R2012a or later, a better choice is the integral function using the 'ArrayValued' argument:
int_w = integral(w, 0, 1, 'ArrayValued',true);
8 Comments
Star Strider
on 13 May 2016
Donyau Chiang’s Comment is duplicated here:
Thank you, Mr. Strider for your quick answer. Is it possible to use inline to create a function and integrate it because my MatLab version does not have quadv command yet? Otherwise, I have to update my version. Anyway, thank you for your instruction. BR Donyau
Star Strider
on 13 May 2016
My pleasure.
The quadv function was introduced prior to R2006a, so you should have it.
Using the anonymous function is preferable to using the inline function. Your anonymous function will work with both quadv and integral. I tested it with both.
Donyau Chiang
on 13 May 2016
Star Strider
on 13 May 2016
My pleasure.
What version are you using?
Donyau Chiang
on 14 May 2016
Star Strider
on 14 May 2016
Thank you.
My pleasure.
I would have preferred that you Accept my Answer if it solved your problem.
Donyau Chiang
on 17 May 2016
Star Strider
on 17 May 2016
My pleasure.
Categories
Find more on Bessel functions 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!

