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 11.02.2016, 02:22 GMT-5
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 24.01.2012, 03:10 GMT-5
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 24.01.2012, 12:52 GMT-5
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: 9 years ago 10.02.2016, 00:56 GMT-5
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: 9 years ago 11.02.2016, 01:53 GMT-5
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: 9 years ago 11.02.2016, 02:22 GMT-5
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.