Error while executing integral function

3 views (last 30 days)
function A = bessel_coefficients(F,alpha)
A = zeros(size(alpha));
s = size(alpha);
N = s(2);
for ii = 1:N
a = 2/(besselj(1,alpha(ii)))^2;
b = @(r) besselj(0,alpha(ii)*r);
fun = @(r) F(r)*b*r;
A(ii) = a * integral(@(r) fun,0,1,"ArrayValued",true);
end
The error message I have recieved :
Operator '.*' is not supported for operands of type 'function_handle'
Error in integralCalc/iterateArrayValued (line 156)
fxj = FUN(t(1)).*w(1);
Error in integralCalc/vadapt (line 130)
[q,errbnd] = iterateArrayValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Error in bessel_coefficients (line 10)
A(i) = a * integral(@(r) fun,0,1,"ArrayValued",true);
I cant seem to figure out the solution to this issue. Any hints on what i can do?
  2 Comments
madhan ravi
madhan ravi on 8 Apr 2020
Would you mind providing the datas of F and alpha?
Mahmoud Abdalhamid
Mahmoud Abdalhamid on 8 Apr 2020
F is a (vectorized) function handle defining the initial position F(r)
alpha is a 1 × N row vector
the values of F and alpha change but here is an example of what F might be F = @(r) 0.2*cos(7*pi*r/2); N = 30;

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 8 Apr 2020
Edited: Ameer Hamza on 8 Apr 2020
Change the line
fun = @(r) F(r)*b*r;
to
fun = @(r) F(r)*b(r)*r;
and replace
A(ii) = a * integral(@(r) fun,0,1,"ArrayValued",true);
with
A(ii) = a * integral(fun,0,1,"ArrayValued",true);
  7 Comments
Mahmoud Abdalhamid
Mahmoud Abdalhamid on 8 Apr 2020
Thanks Ameer that was very helpful
Ameer Hamza
Ameer Hamza on 8 Apr 2020
Steven, thanks for your input.
Mahmoud, I am glad to be of help.

Sign in to comment.

More Answers (0)

Categories

Find more on Data Type Identification in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!