Recursive Anonymous Function Matlab
问题 I know that this is not what anonymous functions are made for, but just as a puzzle I tried to make a recursive function via anonymous functions. The prototype of recursive functions obviously is the factorial function. The problem is that it is difficult to make a case distinction within the anonymous functions. What I managed to do so far is following: f=@(cn,n,f)eval('if n>1; f(cn*n,n-1,f);else;ans=cn;end'); f=@(n)f(1,n,f); Or alternatively: f=@(cn,n,f)eval('if n>1; f(cn*n,n-1,f);else;disp