I want to create an anonymous function which takes the first output variable of an existing vector function in file in Matlab. For example, the existing vector function in a separate M-file is
function [y1,y2] = myfun(x1)
y1 = x1;
y2 = x1^2;
end
Is it possible to create an anonymous scalar function from myfun() which takes the value of y1? Thank you for any suggestions.
P.S. I am doing this because actually my original function is more like
function [y1,y2] = myfun(x1,x2)
y1 = x1+x2;
y2 = x1^2+x2^2;
end
and I want to create a scalar function y1 with only one parameter x1 (pass a known value of x2 to the anonymous function).