Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

How to remove the history record in the m-file exported from COMSOL

Please login with a confirmed email address before reporting spam

Hello all,

I hope this is not a silly question. With "Save as Model M-file", COMSOL can generate a m-file that can be used in MATLAB with LiveLink.

But I realized that the generated m-file contains every step I did in COMSOL GUI. For example, if you set the Geometry Import several times in COMSOL, specified "1.mphbin" first, then imported. And you realized you chose the wrong file. You then changed to "2.mphbin", imported. You realized you did it wrong again.....

After changing the filename several times, you export the model to a m-file. It will look like:

model.geom('geom1').feature('wp1').geom.feature('imp1').set('filename', '1.mphbin');
model.geom('geom1').feature('wp1').geom.feature('imp1').importData;
model.geom('geom1').feature('wp1').geom.feature('imp1').set('filename', '2.mphbin');
model.geom('geom1').feature('wp1').geom.feature('imp1').importData;
model.geom('geom1').feature('wp1').geom.feature('imp1').set('filename', '3.mphbin');
model.geom('geom1').feature('wp1').geom.feature('imp1').importData;
model.geom('geom1').feature('wp1').geom.feature.remove('imp1');
model.geom('geom1').feature('wp1').geom.feature.create('imp1', 'Import');
model.geom('geom1').feature('wp1').geom.feature('imp1').set('filename', '1.mphbin');
model.geom('geom1').feature('wp1').geom.feature('imp1').importData;
model.geom('geom1').feature('wp1').geom.runAll;

But it is pretty clear that the first 7 lines don't make any sense. The problem not only exists for geometry, it also exists for mesh, solver, and so on.

Is there a way to remove all the history actions so I can get a clean m-file?

Thanks.

Best,
Kan

5 Replies Last Post Feb 11, 2016, 2:22 a.m. EST
Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jan 24, 2012, 3:10 a.m. EST
Hi

try to do a File reset model, before you save your file, this would clean out most of the "old junk" (I often do an Edit clear all Solutions & Mesh, then a reset model and then I save it, This uses quite less disk file, but OK you must rerun it fully as you loose all your solved data like that, and the history of your model building, if for any reason you are interested in that

--
Good luck
Ivar
Hi try to do a File reset model, before you save your file, this would clean out most of the "old junk" (I often do an Edit clear all Solutions & Mesh, then a reset model and then I save it, This uses quite less disk file, but OK you must rerun it fully as you loose all your solved data like that, and the history of your model building, if for any reason you are interested in that -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jan 24, 2012, 12:52 p.m. EST
Thank you so much Avar. Problem solved!
Thank you so much Avar. Problem solved!

Please login with a confirmed email address before reporting spam

Posted: 8 years ago Feb 10, 2016, 12:56 a.m. EST
hi
what is the meaning of "reset model"?
hi what is the meaning of "reset model"?

Please login with a confirmed email address before reporting spam

Posted: 8 years ago Feb 11, 2016, 1:53 a.m. EST
I think it means clean all the model-building history (so you won't be able to undo), mesh data (if any), and solution data (if any).
I think it means clean all the model-building history (so you won't be able to undo), mesh data (if any), and solution data (if any).

Henrik Sönnerlind COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago Feb 11, 2016, 2:22 a.m. EST
Hi,

In the GUI, it is File->Compact History.

This will not delete mesh and solutions.

Regards,
Henrik
Hi, In the GUI, it is File->Compact History. This will not delete mesh and solutions. Regards, Henrik

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.