Real Technology Tools

Simulink Tutorial: How to Get the Parameters of a Simulink Block from MATLAB

In the article, you will learn:

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

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', ...
'FollowLinks', 'on', 'LoadFullyIfNeeded', 'on', 'Variants', 'allVariants');
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
 
end

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

If you want to learn more about the tools that helped me stop wasting time doing mindless work (such as generating Excel reports, Word documents, or creating clean and simple user interfaces) I wrote a small reference book about it:

 

Exit mobile version