## MATLAB Fast Automation: Tired of Working? Here's Your Step-by-Step Action Plan to Automate Your Work With MATLAB.

In the article, you will learn:

• How to review the block parameters of one block in your model
• How to review the block parameters of every block in your model

## Get the Parameters of a Single Block

If you want to review a Simulink model, you will probably want to access some of the properties of the blocks of your model so that you can write them down somewhere (e.g. in a Word file).

• Get all block parameters: you can access any field of a Simulink block by using its handle:
% gcb gives you the path of the block you clicked on
pathBlock = gcb;
% get the handle of the block
blockHandle = get_param(pathBlock, 'Handle');
% get the structure of the desired block with every field
block = get(blockHandle)
• Get a specific block parameter: you can then  access the different fields of your block:
% get the name of your block
block.Name
% get the BlockType of your block
block.BlockType
% get the parent of your block
block.Parent
block.LinkStatus

The variable “block” of this example is a structure in which every field represents one of the parameters of the block that you clicked on.

## Review the Parameters of Every Block

To review your model, all you have to do is apply this to every block:

function getModelInfo(model)

% find all the paths of the blocks in your model
blocks = find_system(model, 'LookUnderMasks', 'on', ...
for i = 1:numel(blocks)
% get the handle of the block
blockHandle = get_param(blocks{i}, 'Handle');
% get the structure of the desired block with every field
block = get(blockHandle)

% get the name of your block
block.Name
% get the parent of your block
block.Parent
end

return

The function find_system finds every block of your model. The arguments used in the code above are:

• LookUnderMasks set to on to find blocks in a subsystem with a mask
• FollowLinks set to on to find blocks inside library blocks
• LoadFullyIfNeeded set to on to find blocks in subsystems partially loaded
• Variants set to allVariants to find blocks in subsystem variants