Get Simulink Block Object

8 ビュー (過去 30 日間)
Timo Dietz
Timo Dietz 2022 年 6 月 27 日
編集済み: Timo Dietz 2022 年 7 月 4 日
I switched from Matlab 2020 to 2022 and now I encounter the following issue:
I need to get direct access to the objects of all blocks in a Simulink model. This way I do not need to use "get_param" for each
property of the block handle.
In 2020 it worked this way (getting all block paths, then all handle IDs of all blocks and finally calling 'handle' delivered the object):
blockList = find_system(modelName, 'RegExp', 'on'); % list of all block paths in Simulink model
handlesList = get_param(blockList,'handle'); % list of handle IDs
>> handle(handlesList{7})
ans =
The 'handle' call in Matlab 2022 does not return the object, anymore:
>> handle(handlesList{7})
ans =
In both versions, directly getting the parameter 'object' from the list of block paths works, but that does not seem to be a valid parameter - at least it's not documented:
>> objectList = get_param(blockList,'object');
>> objectList{7}
ans =
Constant with properties:
Name: 'Constant'
Is there another ('official') way of getting hands on all objects of Simulink blocks inside a model?
Thanks a lot
  3 件のコメント
Paul 2022 年 6 月 28 日
You got the question. I was unaware of that method to access the handle that way and modify block properties.
I'm surprised that set_param and get_param are remarkably slower.


回答 (1 件)

Pravarthana P
Pravarthana P 2022 年 6 月 30 日
Hi Timo Dietz,
I can understand that you are trying to get the objects of blocks used in Simulink through “handle” function. From R2022a version we have updated the objects of Simulink which is different from the “handle” function API used in the previous versions of Simulink, so usage of “handle” not returning block objects is an expected behavior in R2022a.
We are working on the documentation regarding the new API and the function to get the block objects directly may be available in future releases.
The suggested workaround will be to use “get_param()” to get the block objects. Kindly refer to the following documentation for further details: Get parameter names and values - MATLAB get_param (
Hope this information helps you!!
  1 件のコメント
Timo Dietz
Timo Dietz 2022 年 7 月 1 日
編集済み: Timo Dietz 2022 年 7 月 4 日
Thanks for the reply.
Can you tell me whether the parameter 'object' will be valid also in future releases? Currently, it does not seem to be documented being a 'get_param()' parameter.
Sure, I could change the code and get the object by 'get_param(handle, 'object')' but it would be great to know whether that's only a workaround or a long-term solution.
Many thanks in advance,



Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by