count_calls.m

来自「matlab programming for engineers(2nd)书籍源」· M 代码 · 共 18 行

M
18
字号
function fhandle = count_calls(initial_value)

% Save initial value in a local variable
% in the host function.
current_count = initial_value;

% Create and return a function handle to the
% nested function below.
fhandle = @increment_count;

   % Define a nested function to increment counter
   function count = increment_count
   current_count = current_count + 1;
   count = current_count;
   end % function increment_count
   
end % function count_calls

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?