The Model History
The model contains its entire modeling history corresponding to every settings added once to the model. When you save a model as an M-file, you get all the operations performed to the model, including settings that are no longer part of the model.
Using the model history is a convenient way to learn the COMSOL API. The latest settings enter in the command Desktop being listed at the end of the M-file.
The model history is automatically enabled when the model is created in the COMSOL Desktop. It is however possible to manually disable the model history recording from the MATLAB prompt with the command:
model.hist.disable
The functions
mphload
and
mphopen
automatically disable model history when loading a model.
To enable the model history, enter the command:
model.hist.enable
Compacting the Model History
To clean the M-file for the model so that it contains only the settings that are part of the current model you need to compact the model history before saving the model as an M-file.
To compact the model history in the COMSOL Desktop, from
File
menu (Windows users) or from the toolbar (Mac and Linux users), select
Compact History
(
).
To compact the model history at the MATLAB prompt enter the command:
model.resetHist