Comsol-Matlab tutorial

From Applied Optics Wiki
Revision as of 15:17, 7 January 2013 by Jethro (talk | contribs)

Jump to: navigation, search

Setting up the software

The first step is installing the correct software. You will require a licensed copy of Comsol 3.5a, and a licensed copy of Matlab 2007. Both of these can be installed from the VPM repo.

A Comsol-Matlab (CM) interface is initialised by running the command comsol_35a matlab. This should start a java instance of Matlab 2007 with Comsol commands enabled. To check the link try the command flclear fem which will not work in a standard Matlab instance.

Within the CM interface all Matlab functionality is unchanged. In addition to this a new set of Comsol commands are available, all of which are documented and have standard help functionality.

Building a model

There is no particular correct way to build your model in a CM interface, it is not all that intuitive. Personally, I have found that the best way to work with and build models is within a standard Comsol session. Once built a model can easily be manipulated within the CM interface. The internal language used by Comsol is fully compatible with Matlab script, and as you build a model Comsol saves the commands in a Matlab usable format in a file named myModel_history.m.

Memory issues