I have a local function defined in an m-file. For example:
% begining of public_function.m file
function fh = public_function( )
%
% do some computation...
fh = @local_function; % return function handle to local function defined below
function y = local_function( x )
%
% a local function inside public_function.m file
%
% some manipulation on x
y = x;
% end of public_function.m file NOTE THAT local_function is NOT nested
Now, I would like to call local_function
from command line (and not from public_function
). I was able to do so using the function handle returned from public_function
:
>> fh = public_function(); % got handle to local_function
>> y = fh( x ); % calling the local function from command line :-)
My question:
Is there any other way (apart from explicitly pass the function handle) to call local function from command line (or other m-file/functions)?
More precisely, I want a method to access any local function in a file (provided that I know its name). So, if I have public_function.m
file (and function) and I know that local_function
is local to that file, is there a way to access local_function
from command line ?