Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to make an anonymous function without output? [duplicate]

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.

like image 745
Argyll Avatar asked Oct 15 '25 03:10

Argyll


1 Answers

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();
like image 155
Luis Mendo Avatar answered Oct 17 '25 21:10

Luis Mendo