The Matlab function superclasses returns the names of all parents of a given class.
Is there an equivalent to find all classes derived from a given class, i
I moved the code since it was > 200 lines onto the Github repository getSubclasses. You are welcome to reqeut features and post bug reports.
Given a root class name or a meta.class
and a folder path, it will traverse down the folder structure and build a graph with all the subclasses derived from the root (at infinite depth). If the path is not supplied, then it will recurse down from the folder where the root class is located.
Note, that the solution is local, and that is why it is fast, and relies on the assumption that subclasses are nested under some subfolder of the chosen path.
List all subclasses of the sde
class. You will need R2015b to be able to produce the graph, or you can use the output and the FEX submission plot_graph() to produce a dependency graph.
getSubclasses('sde','C:\Program Files\MATLAB\R2016a\toolbox\finance\finsupport')
And the output with the edges and node names:
names from to
________ ____ __
'sde' 1 1
'bm' 2 3
'sdeld' 3 6
'cev' 4 3
'gbm' 5 4
'sdeddo' 6 1
'heston' 7 6
'cir' 8 9
'sdemrd' 9 6
'hwv' 10 9
We can compare the result with the official documentation, which in this case lists the SDE hierarchy, i.e.
On Win7 64b R2016a
getSubclasses('sde','C:\Program Files\MATLAB\R2016a\toolbox\finance\finsupport')
getSubclasses('sde',matlabroot);