find_system versus Simulink.findVars

3 visualizaciones (últimos 30 días)
Bo
Bo el 11 de Jul. de 2013
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

Respuesta aceptada

Guy Rouleau
Guy Rouleau el 12 de Jul. de 2013
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.
  1 comentario
Bo
Bo el 17 de Jul. de 2013
Hello Guy,
I have a follow-up to my question above that I hope you (or someone) can help me with...
So far, I've found that the Simulink.findVars is the best option to do what I'm looking for but I'd like to filter further.
Let's say I load up my model using load_system() then find the variables that the model uses by using Simulink.findVars('MyModel').
I just want to confirm that if I use the arguments Simulink.findVars('MyModel', 'WorkspaceType', 'base') that I will get the "addresses" of only those blocks that use a variable from the workspace, and nothing else (as in mask references or model workspaces)?
Thanks in advance,
Bo

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programmatic Model Editing en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by