Comparing Simulink.ConfigSet objects

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.)

 Respuesta aceptada

Jakob Janecek
Jakob Janecek el 27 de Mzo. de 2013
Editada: Stefanie Schwarz el 26 de Sept. de 2025
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 comentarios

John B
John B el 27 de Mzo. de 2013
Hi Jakob,
Thanks for the suggestion. I am comparing ConfigSets as part of an automated simulation environment, so I really just want to know if they are different, without having to write and compare files. The (undocumented, removed in 2013a) isContentEqual() method did just that with no fuss.
The workaround I am using is to just loop through the individual components of the config sets (SolverCC, etc.) and do a pairwise isequal(). This approach works fine - I just miss the convenience of a one-line call. Just another example of the risks of using undocumented functionality.
Thanks again for the answer - I'll mark it as accepted it since it is the 'official' way to do it.
N/A
N/A el 18 de Mayo de 2015
Hello,
is there any way to export or save a differences as HTML file using m-script?
Jakob Janecek
Jakob Janecek el 20 de Mayo de 2015
At the moment there is no API available to get the HTML of a difference report.
Jonas
Jonas el 4 de Jul. de 2019
When I compare two Configuration Sets which I exported to a .mat-file, the compare tool just says that they are different... I want to know which configuration settings are different.compare_config.png
Paul Rancuret
Paul Rancuret el 8 de Ag. de 2019
Editada: Paul Rancuret el 8 de Ag. de 2019
Jonas,
It isn't giving you a direct comparison of the actual settings because the configuration sets are saved with different variable names in the two files. The Config_blink.mat contains a set named 'Configuration,' and the Config_PID.mat contains a set named 'QuickStart_50019_7_1_14_33_36991'. So, the comparison tool is just showing the difference as removing one set and adding a new one from the mat file. If they have the same name, then the difference will be detected as a modification to the variable, and a compare button will allow you to look at the detailed differences for that variable. Just re-save the mat files with the same variable name inside, and the visdiff tool will give you results similar to this:
The comparison window (after clicking compare) then gives what I believe you are looking for.
Regards,
Paul
Tong Zhao
Tong Zhao el 30 de Mzo. de 2023
Thanks Paul for the correction.
Keith
Keith el 18 de Ag. de 2025
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?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Preguntada:

el 26 de Mzo. de 2013

Editada:

el 26 de Sept. de 2025

Community Treasure Hunt

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

Start Hunting!

Translated by