From: Susan on
The documentation describes this limitation to evalin:

Limitation

evalin cannot be used recursively to evaluate an expression. For example, a sequence of the form evalin('caller', 'evalin(''caller'', ''x'')') doesn't work.

Does anyone have a workaround for this? Sometimes I'd really like to reach up two levels instead of just one.

Thanks,

Susan
From: Bruno Luong on
"Susan " <foowidget(a)gmail.com> wrote in message <hiiq0f$ipu$1(a)fred.mathworks.com>...
> The documentation describes this limitation to evalin:
>
> Limitation
>
> evalin cannot be used recursively to evaluate an expression. For example, a sequence of the form evalin('caller', 'evalin(''caller'', ''x'')') doesn't work.
>

Here is a tip: instead of using eval to reach two levels up, pass x as input arguments to reach two levels down.

Bruno
From: Matt Fig on
Can you give a realistic example of what you are trying to accomplish by this syntax?
From: Matt J on
"Susan " <foowidget(a)gmail.com> wrote in message <hiiq0f$ipu$1(a)fred.mathworks.com>...
> The documentation describes this limitation to evalin:
>
> Limitation
>
> evalin cannot be used recursively to evaluate an expression. For example, a sequence of the form evalin('caller', 'evalin(''caller'', ''x'')') doesn't work.
>
> Does anyone have a workaround for this? Sometimes I'd really like to reach up two levels instead of just one.
==================

You should probably be using nested functions

function aout =A(ain)

x=[]; %initialize x

function bout =B(bin)

function cout =C(cin)

x=2; %function A() can see this


end


end

end
From: Matt Fig on
Maybe I missed the point of the limitation, but copying and pasting from the documentation, gives


>> clear all
>> x = 3;
>> evalin('caller','evalin(''caller'', ''x'')') % Copied from the doc.
x =
3
>> z = evalin('caller','evalin(''caller'', ''x'')')
z =
3
>> evalin('caller','y = evalin(''caller'', ''x'')')
y =
3
>> who

Your variables are:

x y z