Guy on Simulink

Simulink & Model-Based Design

Model Explorer or Command Line? 5

Posted by Guy Rouleau,

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

For a long time, when I needed to find or modify blocks in a large Simulink model, I used the command prompt and functions like find_system, hilite_system and set_param.

For the example described above, I can find the blocks using find_system and see how they are connected in the model using hilite_system:

Finding blocks from command line

To change the Index Search Method, I can use set_param on the previous results:

Configuring blocks from command line

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.

Finding blocks using the Model Explorer

In the list of results, the Path column is a hyperlink I can click to immediately see where the block is in the model.

Finding blocks using the Model Explorer

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

Finding blocks using the Model Explorer

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

Mohsen Nosratinia replied on : 2 of 5

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…

Sreeeraj replied on : 3 of 5

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

Guy Rouleau replied on : 4 of 5

@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.

Joshua Kephart replied on : 5 of 5

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.

Add A Comment

What is 2 + 5?

Preview: hide