Turn a simulink model into a digraph
2 views (last 30 days)
I have a simulink model that I would like to turn into a digraph (<http://www.mathworks.com/help/matlab/ref/digraph-object.html>)
Essentially what I want to do is find all of the blocks... find all of the blocks they are connected to... make this a matrix... and then feed it into digraph.
I'm starting with code similar to this one https://www.mathworks.com/matlabcentral/answers/216496-m-script-how-to-find-which-block-is-connected-to-which-block
which includes things like
allBlks = find_system(myModel,'FindAll','on','FollowLinks','on','Type', 'block');
allPorts = get_param(allBlks(k), 'PortConnectivity');
etc, etc... but that doesn't take care of the complexity of subsystems, multiple ports, bus's, etc. Any ideas? (Or has anybody else tried to solve this problem?)
Monika Jaskolka on 22 May 2018
Edited: Monika Jaskolka on 25 Jul 2019
You may be interested in some functions provided by the Auto Layout Tool available on the File Exchange. Those provided in src/GraphPlot_Portion, particularly blocksToDigraph.m and plotSimulinkDigraph.m, deal with generating a digraph from a Simulink subsystem.