How can I know the number of blocks or subsystems of the same kind, in a Simulink model, from Matlab (.m file)?
Thanks for your help.
See
>> doc sldiagnostics
and in particular
>> nBlocks = sldiagnostics('modelname','CountBlocks');
Note that sldiagnostics tells you how many of each type of block, so you'll need to parse it out, and do some math, to get the total block count.
There is a discussion of doing something similar here