find_system versus Simulink.findVars
4 次查看(过去 30 天)
显示 更早的评论
I have a reasonably large model (~30,000 blocks) I'm trying to automate the changing of variable references in. The goal is to put "this_prefix." in front of variable references for a specific field (i.e. 'Value' for block type "Constant", 'Gain' for block type "Gain", etc.) in order to put all 1800+ Workspace variables into one structure; however, there is a catch. I want to leave blocks that are masked alone but I do want to change the fields in the parent masking block.
If possible, I'd like to look at only those blocks which use a variable in the workspace (hence the Simulink.findVars command) but cannot use the argument " 'LookUnderMasks', 'none' " that is present in find_system command because, as far as I can tell, it doesn't exist.
So far, I can get the "block address" for each block, and get_param works nicely for each one; I just can't figure out how to not have the code completely skip a masking block, or even tell if it's looking at them.
I'm cautious to share any code because it's all proprietary.
Thanks in advance.
-Bo
0 个评论
采纳的回答
Guy Rouleau
2013-7-12
Simulink.findVars returns a list of simulink.variableusage objects.
This object has a "Source" property telling you where the variable comes form. Using that should allow you to only rename the variables you are looking for.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Programmatic Model Editing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!