How to retrieve a subblock name at initalization.
显示 更早的评论
Dear community, I want to create a subblock which returns the name of the subblock as a String. (The subblock name shall be used as a key to retrieved a value from a database and I want to make the access of the database visible in simulink).
Currently I use a masked subblock with a 'Parameters' variable 'MyName'. The subblock contains a constant, which returns the value of a variable 'MyName'. The variable 'MyName' shall be initialized with the name of the subblock it belongs to.
A code like MyName = get_param(gcb,'Name'); does not work in the Initialization box for the dialog variable 'MyName'.
Since the subblock name is static I guess Simulink provides something like 'this.Name', which is available at initialization time. Is this kind of function available?
Can anyone help?
采纳的回答
更多回答(1 个)
Doug Eastman
2013-1-4
Another simpler option might be to just use a constant block with the value:
uint8('LookupKey')
You could then hide the block name and expand the block so that value text is visible.
类别
在 帮助中心 和 File Exchange 中查找有关 Code Generation 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!