If you notice, the error says: “Number of blocks in the block diagram 'IntegratedPlant' and all models it references exceeds the license limit of 1000 nonvirtual blocks.”
You cannot use “find_system” command by itself to obtain the contents of a referenced model. Hence when you are using “length(find_system())” you are subliminally discarding the contents of referenced models.
To understand the actual number of virtual blocks, a search is needed to be performed inside the referenced models also:
There are two possible workarounds that can be used to find the referenced models:
- Use the “find_mdlrefs” command in conjunction with the “find_system” command. For example, to find the relational operator blocks inside all of the referenced models that have the relational operator property set to "==" in the demo model "sldemo_mdlref_basic":
[r, b] = find_mdlrefs('sldemo_mdlref_basic');
load_system(r{1})
rel_blks = find_system(r{1},'FindAll', 'on','BlockType','RelationalOperator','Operator','==')
Note: The last two commands can be used in a "for" loop if you have multiple referenced models.
- A second possible workaround is to use the MATLAB file submitted in the following MATLAB File Exchange link:
Note that MathWorks does not guarantee or warrant the use or content of these submissions. Any questions, issues, or complaints should be directed to the contributing author.
I would also like to suggest about the “sldiagnostics” functionality. See this link:
Most of the checks done by “sldiagnostics” help you gather an understanding of the model as a whole. If you could take a look at the following Blog post: