フィルターのクリア

Programmatically get all block parameters

52 ビュー (過去 30 日間)
Alexander Boll
Alexander Boll 2024 年 7 月 12 日 6:15
回答済み: Shubham 2024 年 7 月 12 日 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?

回答 (1 件)

Shubham
Shubham 2024 年 7 月 12 日 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.

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by