%% Anonymous Functions %% % Another way to perform the circle calculations is to use anonymous % functions. % % This can be done directly at the command prompt (or in our current % file). % % We type circumference = @(r) 2*pi*r %% % and area = @(r) pi*r.^2 %% % Anonymous functions are evaluated like standard math functions. % % To get the circumference of a circle with radius 5 we use circumference(5) %% % To get both values we use, e.g., circledata = [circumference(5); area(5)] %% % Vectorized usage: circledata = [circumference([2 4 6]); area([2 4 6])]