Is it possible to create function handles to constructors of a class using STR2FUNC?

3 views (last 30 days)
I am trying to create a function handle to the constructor of a class, 'linegraph', which resides in a package called 'graphics'.
import graphics.*
fHandle = @linegraph
fHandle2 = str2func('linegraph')
The latter function handle is not constructed appropriately. However, if I specify the fully qualified method name, it works fine.
fHandle = str2func('graphics.linegraph')

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 23 Oct 2009
The ability to create function handles to class constructors, defined inside packages is not available in MATLAB 7.9 (R2009b).
The only workaround is to use fully qualified method names.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2009b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!