Borrar filtros
Borrar filtros

Programmatically get all block parameters

52 visualizaciones (últimos 30 días)
Alexander Boll
Alexander Boll el 12 de Jul. de 2024 a las 6:15
Respondida: Shubham el 12 de Jul. de 2024 a las 9:16
Some blocks have special parameters, that are not listed in
get_parameter(block, 'DialogParameters')
get_parameter(block, 'ObjectParamters')
For example, the MATLAB function block reveals its content with the object in
get_param(block, 'MATLABFunctionConfiguration')
Which is listed in neither. How to get a list of all a block's parameters, even exotic ones? Is there maybe a block object to circumvent such an awkward search, for specific parameters you don't even know exist?

Respuestas (1)

Shubham
Shubham el 12 de Jul. de 2024 a las 9:16
Hi Alexander,
I understand that you want to access all the parameters of a block. However, you are not able to access some hidden parameters, which are not listed in "BlockParameters" and "DialogParameters". In Simulink, some parameters are "hidden" and do not appear by default when you use “get_param(blockPath, 'ObjectParameters')” or get_param(blockPath,'dialogParameters') to query a block's parameters.
Below is the MATLAB Script to list the block parameters using block handle:
% Accessing all block parameters by using Block Handle :
params = get_param("model_name/MATLAB Function","Handle")
blockParameters = get(params);
% Display all properties
disp('List of block parameters:')
parameterNames = fieldnames(blockParameters);
for i = 1:length(parameterNames)
disp(parameterNames{i})
end
The parameter "MATLABFunctionConfiguration" is not present in the list.
Unfortunately, there is no built-in command to list all hidden parameters directly. However, if you know the name of the hidden parameter, you can retrieve its value as follows:
get_param(block_path, 'MATLABFunctionConfiguration')
If you don't know the names of the hidden parameters for a specific block but suspect their existence, you can try the following approaches:
  1. You can check the documentation of the block you are using.
  2. If you suspect the name of a hidden block parameter, try accessing it directly using “get_param” to confirm it.
Hope it helps.

Categorías

Más información sobre Programmatic Model Editing en Help Center y File Exchange.

Productos


Versión

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by