Is there a way to make an anonymous function without output?
I have variable for function_handle whose starting, default value is to do nothing. So I am doing func=@()[];. But I am also curious if there is a way to truly do nothing and output nothing like a .m file for a function that has no return.
Whichever approach, I would still like isa(func,'function_handle') to return true.
To return multiple outputs from an anonymous function you can use deal. This also works to return no output. In addition, (thanks to @Wolfie), varargin can be used to allow a variable number of inputs:
func = @(varargin) deal();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With