Simulink block handles change

2 views (last 30 days)
I am analyzing Simulink models programmatically. For this I need to give every block an ID. I thought about using a block's handle for this -- e.g. the handle "2.000122070312500" for the block "data_in". My problem is, that these handles actually change each time a model is loaded with "load_system", destroying my IDs. After a clean Matlab restart, the handles are restored again, indicating there is some cache for handles.
Is there a way to clear the handle cache, so that handles will be reset and usable as IDs?
Is there another system to give each block an ID or should I just write my own?

Accepted Answer

Alexander Boll
Alexander Boll on 15 Jul 2021
I found out, that a block's property 'Name' cannot be duplicated in the same subsystem. This means, that unique IDs can be given by using all the parent subsystems of a block plus it's name. As subsystems are also just blocks, this means, the parent hierarchy is duplicate free, as well.
E.g. the blocks called "Add1", "Add2" and "Clock" in the subsystems "Main/Precomputation" may be given the unique IDs "Main/Precomputation/Add1", "Main/Precomputation/Add2", "Main/Precomputation/Clock".
I did not yet find a way to clear the handle cache, but this way, I don't need to.

More Answers (0)

Categories

Find more on Modeling in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!