## 10X Your Productivity: Grab Your Free Online Course Right Now! |

You may want to disable every library link in your model. This could happen if:

- You are using a non-official version of your model that you would like to manipulate more easily
- You want to apply modifications to your entire model or a subsystem of your model programmatically

In this article, you will learn:

- How to find every block of your model
- How to modify its parameters

## Find Every Block of your Model

To do this, you can use the following command:

blocks = find_system(pathName, 'FollowLinks','on', 'BlockType', 'SubSystem');

- In this example, we use
**‘FollowLinks’**set to**‘on’**in order to look inside the library blocks. We use**‘Subsystem’**because the**‘BlockType’**of a library block is necessarily a subsystem.

**pathName**is the path that you want to start the search from. Most of the time it will be the root of your model, but that is not necessarily the case, so we will define the pathName as following:

pathName = gcb;

**gcb**is merely the path of the block you clicked on. If you want to apply it to your model, you can change gcb to the name of your model.- The variable “
**blocks**” is a vector of cells; each cell contains the path of one of the subsystems of your model.

## Disable the Link of a Library Block

To disable the link of a library block, we will use the following command:

set_param(blockPath,'LinkStatus','inactive');

Then, we can apply this command iteratively to every block of your model as follows:

for i=1:length(blocks) set_param(blocks{i},'LinkStatus','inactive'); end

Since the variable blocks is a vector of cells, we need to access the content of the cell (not just the cell itself). This is why we use braces instead of parenthesis to modify the library link of the desired block.

If you use the following script, you can just click on a subsystem and apply the script. Every block inside the selected subsystem will have their library link disabled:

pathName = gcb; blocks = find_system(pathName, 'FollowLinks','on', 'BlockType', 'SubSystem'); for i=1:length(blocks) set_param(blocks{i},'LinkStatus','inactive'); end

Here are a few articles about doing things in Simulink from a MATLAB script:

- If you want to link a library block from a script: MATLAB-Simulink: Lock a Library Block Programmatically from MATLAB
- If you want to check your model using a script: MATLAB-Simulink: The Basic Requirements to Conquer Model-Based Design