MATLAB: How to extract configuration parameters from a model
simulink
I want to save all the config params from a model so that I can use the same set in another model. How can I do that?
Best Answer
You can save the settings of configuration sets as MATLAB® functions or scripts. Using the MATLAB function or script, you can share and archive model configuration sets. You can also compare the settings in different configuration sets by comparing the MATLAB functions or scripts of the configuration sets.
To save an active or inactive configuration set from the Model Explorer:
Open the model.
Open the Model Explorer.
Save the configuration set:
In theModel Hierarchy pane:
Right-click the model node and selectConfiguration > Export Active Configuration Set.
Right-click a configuration set and selectExport.
Select the model. In theContents pane, right-click a configuration set and selectExport.
In the Export Configuration Set to File dialog box, specify the name of the file and the file type. If you specify a .m extension, the file contains a function that creates a configuration set object. If you specify a .mat extension, the file contains a configuration set object.
ClickSave. The Simulink® software saves the configuration set.
You can load configuration sets that you previously saved as MATLAB functions or scripts.
To load a configuration set from the Model Explorer:
Open the model.
Open the Model Explorer.
In theModel Hierarchy pane, right-click the model and selectConfiguration >Import.
In the Import Configuration Set From File dialog box, select the .m file that contains the function to create the configuration set object, or the .mat file that contains the configuration set object.
ClickOpen. The Simulink software loads the configuration set.
% 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.
Best Answer