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?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Malu
el 19 de Jul. de 2023
Comentada: Malu
el 20 de Jul. de 2023
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 comentarios
Fangjun Jiang
el 20 de Jul. de 2023
visdiff() is the one to use. Check the doc to see its output.
https://www.mathworks.com/help/simulink/model-comparison.html
Respuesta aceptada
Fangjun Jiang
el 19 de Jul. de 2023
Editada: Fangjun Jiang
el 19 de Jul. de 2023
"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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Schedule Model Components en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!