Site icon Real Technology Tools

Unlock Every Custom Simulink Library Block in a Model from MATLAB

Unlock every library link in a model

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

In this article, you will learn:

Find Every Block of your Model

To do this, you can use the following command:

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

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:

 

Exit mobile version