No BSD License  

Highlights from
Closures in the MATLAB Language

from Closures in the MATLAB Language by Jim Hunziker
Demonstration of Closures in the MATLAB Language

closureTest.m
% Make two incrementer functions.
a = makeIncrementer(1);
b = makeIncrementer(100);

% Calling function a repeatedly displays numbers increasing from
% 1.  Note that no variables are stored in the workspace.
a()
a()

% Calling function b repeatedly displays numbers increasing from
% 100.
b()
b()

% a and b are independent and still work when calls to them are
% interleaved.
a()
b()



Contact us at files@mathworks.com