Error with anonymous call: Undefined function "times" for function_handle

조회 수: 5 (최근 30일)
Martin Nors Pedersen
Martin Nors Pedersen 2013년 10월 30일
편집: Martin Nors Pedersen 2013년 10월 30일
Hello everyone
i have a quite long formula which i have attempted to split up into two separate functions. I would then like to call the first function within the second function when i integrate the second function - but i run in to the error message shown below:
Undefined function 'times' for input arguments of type
'function_handle'.
i have googled and can see that many have been given this type of problem when they forget to add the variable in the function call. but as far as i can see, i call the function correct and still get the error - can anyone see what i am doing wrong? any help or suggestion would be greatly appreciated.
My code is shown below:
R = 5;
epsR = 25;
eps = epsR/R;
Qrange = 0.01:0.001:2;
Rdot = @(x) R.*sqrt(sin(x).^2+eps^2.*cos(x).^2);
fun_P = @(y) ((3.*sin(Qrange.*Rdot(y))-3.*...(Qrange.*Rdot(y)).*cos(Qrange.*Rdot(y)))./(Qrange.*Rdot(y).^3)).^2.*sin(y);
P_elip = integral(fun_P,0,pi/2,'ArrayValued',1);
as you can see, i make sure to use Rdot(y) and not just Rdot in my code. i have checked the Rdot function and i works fine e.g. Rdot(1) = 14.1476.
ps. i know i use more parenthesis than i strictly have to, but the help keep track of the different terms. i hope it is not too unclear
  댓글 수: 2
Walter Roberson
Walter Roberson 2013년 10월 30일
If I copy and paste that into R2013b then I do not get an error.
Martin Nors Pedersen
Martin Nors Pedersen 2013년 10월 30일
편집: Martin Nors Pedersen 2013년 10월 30일
I just checked again and you are right - i checked it several times back then and i got an error message each time. at least it works now :)
btw., in case someone else would like to calculate the scattering from an ellipsoid: there a mistake in the code above. as it stands now, only Rdot(y) is cubed in the denominator - it should be (Qrange.*Rdot(y)).^3

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by