Classdef: Difference between revisions

134 bytes added ,  1 February 2016
→‎Not Supported: Added another workaround for function handles to fcns in packages
(→‎Not Supported: corrected information)
(→‎Not Supported: Added another workaround for function handles to fcns in packages)
Line 52: Line 52:
For example if we have <code>+mypackage/myfunc.m</code>, creating a function handle as <code>fh = @mypackage.myfunc</code> won't work.
For example if we have <code>+mypackage/myfunc.m</code>, creating a function handle as <code>fh = @mypackage.myfunc</code> won't work.
As a workaround, we can create an indirection using an anonymous function <code>fh = @(varargin) mypackage.myfunc(varargin{:})</code>.
As a workaround, we can create an indirection using an anonymous function <code>fh = @(varargin) mypackage.myfunc(varargin{:})</code>.
Similarly for static class methods where <code>fh = @MyClass.myfunc</code> isn't yet supported.  
Similarly for static class methods where <code>fh = @MyClass.myfunc</code> isn't yet supported. Another workaround for package function handles is to use <code>str2func</code>, e.g. <code>fh = str2func ("mypackage.myfunc")</code>.


A fuller example is also given below:
A fuller example is also given below:
39

edits