MATLAB: Elliptical Integral of second kind in function

elleiptical integralfuntions in script

Hello,
I am trying to get the value of an elliptical integral of second kind, using a function. Now with first kind, this is not a problem:
K = @(r,x) ellipke(k(r,x));
But for some strange, not understandable reason, it is not possible just to get the value of the integral of second kind, this doesn't work:
[K,E] = @(r,x) ellipke(k(r,x));
So question is, how can i get the value for E, as function of k(r,x). I cannot define a function in a file, because then i cannot use k(r,x) as input. Also i cannot define functions in my script (version 2015).
Thanks for your help, Markus

Best Answer

In your example, K is not the output of ellipke but is the anonymous function handle that when evaluated returns the value of ellipke. You want to specify two outputs when you CALL the function, not when you DEFINE it.
k = @(r, x) r.^x;
myEllipke = @(r, x) ellipke(k(r, x)); % One output for definition
rvalue = 0.5;
xvalue = 3;
[K, E] = myEllipke(rvalue, xvalue) % Two outputs for call
Compare this with:
[K2, E2] = ellipke(0.5^3)