Comparing Simulink.ConfigSet objects

조회 수: 23 (최근 30일)
John B
John B 2013년 3월 26일
편집: Stefanie Schwarz 2025년 9월 26일
In Simulink versions prior to R2013a, the Simulink.ConfigSet class had an (undocumented but very useful) isContentEqual() method that compared one set of configuration parameters to another, ignoring the 'Name' and 'Description' properties. This appears to have been removed in R2013a. Equality testing using isequal() works, but includes the above properties in the comparison. So two ConfigSets attached to the same model will always return false for isequal(), since they must have different names.
Is there another way to compare Simulink.ConfigSet objects? I see a computeChecksum() method and a compareComponentWithChild() method, both of which are undocumented. Is there an official way to do it, or am I on my own here?
(Another approach is to convert the ConfigSet to a struct, then test its fields, while ignoring 'Name' and 'Description'. Unfortunately, the ConfigSet contains a set of Simulink.ConfigComponent objects, which have to be converted to structs individually (and some of them contain other Simulink.xyz... objects). So this approach, although it should work, is very kludgy.)

채택된 답변

Jakob Janecek
Jakob Janecek 2013년 3월 27일
편집: Stefanie Schwarz 2025년 9월 26일
You can compare the config sets by saving them to MAT files and then compare those files. For example:
% Get the first config set from the model
configSet = getConfigSet(<model_name>, <config_set_1_name>);
% Save the config set to a MAT file
save('configSet1.mat', 'configSet');
% Get the second config set from the model
configSet = getConfigSet(<model_name>, <config_set_2_name>);
% Save the second config set to a different MAT file
save('configSet2.mat', 'configSet');
% Compare the files
visdiff('configSet1.mat', 'configSet2.mat');
This will generate a report that displays the differences between the two files. You can inspect the results to determine whether there are any functional differences.
  댓글 수: 7
Tong Zhao
Tong Zhao 2023년 3월 30일
Thanks Paul for the correction.
Keith
Keith 2025년 8월 18일
I have to say that it's kind of a pain to have to save config sets into mat files with exactly the same variable names in order to compare them. Isn't there a better way?

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

추가 답변 (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