% [h, xh] = frecorder(f)
%
% Given a function handle f, create two new function handles:
% h - returns the same values as f, and records the inputs
% xh - returns all the arguments at which h was evaluated

function [h,xh] = frecorder(f)

xrec = [];
h = @evalf;
xh = @getx;

function y = evalf(x);
xrec = [xrec, x];
y = f(x);
end

function x = getx()
x = xrec;
end

end