필터 지우기
필터 지우기

i am trying to display the dialog parameters of all blocks in a simulink model. But i am not getting the exact result. Can anyone help me in this?

조회 수: 6 (최근 30일)
i am trying the following program to display the dialog parameters of all blocks using get_param. but this is not showing any result. is there any mistake in the below program?
modelname = 'model1';
load_system(modelname);
blocks = find_system(modelname, 'LookUnderMasks', 'all', 'FollowLinks', 'on', 'Type', 'Block');
% Display the dialog parameters of each block
disp('Block Dialog Parameters:');
for i = 1:numel(blocks)
blockPath = blocks{i};
disp('---');
disp(['Block Path: ', blockPath]);
dialogParams = get_param(blockPath, 'DialogParameters');
if isempty(dialogParams)
disp('No dialog parameters in the block.');
else
disp('Parameters:');
paramNames = fieldnames(dialogParams);
for j = 1:numel(paramNames)
paramName = paramNames{j};
paramValue = dialogParams.(paramName);
% Display the parameter name and value based on the data type
if isnumeric(paramValue)
disp([paramName, ' = ', num2str(paramValue)]);
elseif ischar(paramValue)
disp([paramName, ' = ', paramValue]);
else
disp([paramName, ' = ', class(paramValue)]);
end
end
end
end
  댓글 수: 5
Fangjun Jiang
Fangjun Jiang 2023년 7월 20일
visdiff() is the one to use. Check the doc to see its output.
https://www.mathworks.com/help/simulink/model-comparison.html
Malu
Malu 2023년 7월 20일
i am trying to display only the functional changes between both versions programmatically. i have tried visdiff. but customising a filter to show functional changes only is not working for me. so trying to do in this way

댓글을 달려면 로그인하십시오.

채택된 답변

Fangjun Jiang
Fangjun Jiang 2023년 7월 19일
편집: Fangjun Jiang 2023년 7월 19일
"paramValue" turns to be a struct. All its field values are struct, so your code ends up running this line for all iterations.
else
disp([paramName, ' = ', class(paramValue)]);
end
Using struct2cell(paramValue) and celldisp() might help but I wonder what is the purpose. There are so many dialog parameters for each block and usually there are many blocks in a model.
  댓글 수: 2
Malu
Malu 2023년 7월 20일
My intention is to compare two versions of a simulink model programmatically by comparing all its dialog parameters between respective blocks and see the differences between them. So as a first step i am trying to see the dialog parameters
Malu
Malu 2023년 7월 20일
Above suggestion didnt work for me. It is not displaying any dialog parameters but only displays the blockpath of all specified blocks.
modelname = 'model1';
load_system(modelname);
% Find all MinMax blocks in the model
minmaxBlocks = find_system(modelname, 'BlockType', 'MinMax');
% Display the dialog parameters of each MinMax block
disp('MinMax Blocks and their Dialog Parameters:');
for i = 1:numel(minmaxBlocks)
blockPath = minmaxBlocks{i};
disp('---');
disp(['Block Path: ', blockPath]);
dialogParams = get_param(blockPath, 'DialogParameters');
dialogParams1 = struct2cell(dialogParams);
celldisp(dialogParams1);
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by