Anonymous Functions for updating arrays.
Show older comments
I use many anonymous functions for updating elements within arrays. However generally this requires me to write this kind of thing:
Anew = A;
Anew(i) = anon_f(A,i);
However I feel it should be possible to redefine the function so that all I need is:
Anew = anon_f2(A,i);
Of course, I could always just use child functions instead... An example function:
f = @(state,i)(2*ceil(rem(sum(state(:,i).^3),1)) - 1);
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!