The anonymous function "remembers" the value n had when the anonymous function was created, so it will do what you want when it is called. You can check what the anonymous function "remembers" using the functions function. [As its documentation states, you should only use this for diagnostic and debugging purposes.]
To answer what I expect you will ask next:
- No, there is no way to have the anonymous function use the "remembered" value as part of its display.
- No, there is no way to change the "remembered" value of n without recreating the anonymous function.
But rather than create a bunch of anonymous functions that are all very similar, why not just create one that's more flexible?
A = @(beta, n) 0.5*(beta(n) + beta(n+1));
Or if you want a function that will process all of beta at once, look at movsum and/or movmean.