Today I would like to ask you a question.
This week I received a large model where I wanted to find all the Lookup Table blocks and modify their Index Search Method parameter. Since the model was quite large and I was not familiar with it, manually navigating to each block, opening its dialog and modifying it was not an option.
So my question is: How would you accomplish this task?
Here are two options I considered.
Using functions at the MATLAB command prompt
To change the Index Search Method, I can use set_param on the previous results:
Using the Model Explorer
Recently, I started using the Model Explorer for this type of task and I think it is very efficient.
For the same task as above, I can easily search by block type. One thing I like is that I do not need to remember the exact string for the block type. The drop down looks at my model and offers me a list based on the blocks in my model.
In the list of results, the Path column is a hyperlink I can click to immediately see where the block is in the model.
To edit the Index Search Method for all the blocks found, I:
- Add a column for this property
- Select all the blocks using "shitf+Click"
- Set the value for one instance, and it applies to all selected blocks
Now it's your turn
What is your workflow to find and edit blocks in a large model? Let us know by leaving a comment here.
5 CommentsOldest to Newest
Model Explorer all the way…
One can turn that for loop into a one-liner as well
cellfun(@(x) set_param(x, ‘IndexSearchMethod’, ‘Binary Search’), blks)
Command line all the way…
I tried using the model explorer and found it is very productive. But I am facing a limitation changing the parameters at once. for e.g.: my model having 5 constant blocks and from my search result when I tried changing the value independently it is possible, but when I am selecting more than one constant blocks the option for setting the value is disabled.
It would be better if Matlab allow the user to change the values of multiple block at once
@Sreeraj: It is possible to select multiple Constant blocks and change their value all at once. In this post, I do it for the Index Search Method of the Lookup Table block, but it also works with any block.
I am not sure why it is not working for you. I recommend contacting technical support.
I know this is an old post, but I stumbled across it recently and wanted to make use of it. It will be much easier to demonstrate this methodology to less experienced Simulink developers on my team than it would be to tell them to go write a quick script. One thing I am running into however, is that editing of blocks inside of model references is disabled. You can get it to work if you manually open all the model references in the model hierarchy pane, that is not feasible for large, complex hierarchies.
Do you know of a workaround for this or a way to quickly open all models in a hierarchy in the model explorer (talking hundreds of models here)?
I tried loading them all with a load_system loop, but just loading them is not enough to get them to display in the hierarchy pane at the top level, which is what seems to be required to get multiple block editing to work across different model files.