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
Posted 24 gen 2012, 02:46 GMT-5 Interfacing Version 4.0, Version 4.0a, Version 4.1, Version 4.2, Version 4.2a, Version 5.2 5 Replies
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
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 feb 2016, 02:22 GMT-5