fetch masked subsystem LSB value using Matlab script

3 visualizzazioni (ultimi 30 giorni)
hruthik
hruthik il 30 Giu 2025
Risposto: Soumya il 5 Ago 2025
am unable to fetch the LSB value in my model but am getting for all other block exept for masked subsystem using script

Risposte (1)

Soumya
Soumya il 5 Ago 2025
I understand that you are trying to fetch the LSB value from a block inside a masked subsystem in Simulink using MATLAB scripts, and while it works for normal blocks, it fails for masked subsystems because the parameters are hidden behind the mask. To access parameters inside a masked subsystem, you need to use the ‘LookUnderMasks’ option in find_system. This option tells MATLAB to look inside masked blocks and return the internal blocks that would otherwise remain hidden, which is necessary to locate the block holding the LSB value.
To resolve this issue, you can follow the given steps:
  • Use find_system with the 'LookUnderMasks' as 'all' to confirm that internal block path exists:
allBlocks = find_system(gcs, 'FollowLinks', 'on', 'LookUnderMasks', 'all', 'BlockType', 'Outport');
  • If you have defined it as a parameter, fetch the ‘LSB’ directly as a defined parameter from the path of the internal block obtained, for example:
lsbVal= get_param(allBlocks{1},'LSB');
disp(lsbVal)
  • If not, loop through blocks and check for fixed-point data type, and find ‘LSB’:
for i = 1:length(allBlocks)
dataTypeStr = get_param(allBlocks{i}, 'OutDataTypeStr');
if contains(dataTypeStr, 'fixdt')
dt = Simulink.NumericType(dataTypeStr);
lsbValue = 2^(-dt.FractionLength);
fprintf('Block: %s -> Computed LSB: %g\n', allBlocks{i}, lsbValue);
else
fprintf('Block: %s -> Not fixed-point\n', allBlocks{i});
end
This method ensures MATLAB recognizes the proper hierarchy for masked subsystems and allows you to reliably retrieve or compute ‘LSB’ values without running into indexing or object name errors.
Please refer to the following documentations to get more information on the related functions:
I hope this helps!

Categorie

Scopri di più su Subsystems in Help Center e File Exchange

Tag

Prodotti


Release

R2015b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by