What I want to do is:
a = 5
foo = @(x) x+a
a = 3
foo(1) % recieve 4
Instead, I only get 6! On several other tests I ran, I get that a
is evaluated when foo
is, and and not when foo
is called.
For various reasons, I can't work with
foo = @(x,a) x+a