MATLAB: Documenting an evolving Simulink model

save_systemsimulink

I am running a script that loops through parameters and runs Simulink for each combination. At the end of each model run, I save key results and the parameters in a mat file. But the model itself is changing as we improve the algorithm. In the same mat file, I would also like to save information on the model setup/topology at a level sufficient to identify if differences in the results are due to differences in the model. (We do not presently use version control software).
What is the best way to save the model setup, if it can be done? My default solution is to save the *.mdl file for each model run, which seems inefficient.

Best Answer

By model setup - if you mean just parameters, then you can of course make them all workspace variables and save the values of those variables in a MAT-file for each run. You can also store your Configuration Parameters setting, by getting the ConfigSet object using the getActiveConfigSet function and save that object also in the MAT-file. However, to save the topology itself, the only other way (besides saving the entire .mdl file) that I can think of is to use the XML Comparison Report that you can save as a ZIP-file. I think you need access to Simulink Report Generator to use the tool though.