|
"Katherine Varela" wrote in message <klpr8u$got$1@newscl01ah.mathworks.com>...
> Hello!
> Can someone please show me how to turn the element of an array that is returned by a function, into a function handle. For example, suppose I was given the function "randfun" :
>
> "function [ fval, gval ] = randfun( x, y )
>
> fval = x^2 + y;
> gval = x^3 + x + 6*y;
>
> end"
>
> When I call the function I would have to feed it numerical values x and y, and
> I would receive numerical values for fval and gval. But what I wish to do is create function handles fval(x,y) and gval(x,y) from the function randfun(x,y) (i.e I cannot access fval and gval directly).
>
Not sure I fully understand your need, but what's wrong with putting those lines in 2 mfiles
function fval = ffun (x,y)
[fval,~] = randfun(x,y);
end
function gval = gfun (x,y)
[~,gval] = randfun(x,y);
end
Then @ffun and @gfun are function handles that return respectively the first and second output.
Bruno
|