How about:
x = evalin('caller', 'x')
There is a limitation however, from Matlab's documentation:
evalin cannot be used recursively to evaluate an expression. For example, a sequence of the form evalin('caller','evalin(''caller'', ''x'')') doesn't work.
However, evalin
is not a great function. Any usage should be avoided imho.