Does anyone have any experience in creating and using
external Matlab functions?
I am running Comsol 4.0a, and would like to be able to pass
parameters to a Matlab function, do some calculations, pass
the results back to Comsol and assign them to a variable. It
would also be really useful to be able to pass back and assign
an array of results to Comsol variables. An example of this
would be in the Chemical Reaction Engineering Module
where one might want to compute externally an array of
reaction coefficients for assignment to Comsol. Is this
possible?
I have no problem launching Live Link and exporting models
to Matlab. However, the procedures for defining and invoking
a Matlab function from within Comsol are unclear in the
documentation. The basic description is:
1. Right click Global Definitions, and then go to Functions=>Matlab
A MATLAB1 node is created.
2. Select the MATLAB1 node, and under Settings, enter in the required
information. This includes the Function name and Arguments. There
is a button for plotting the function, but it invokes an error message
saying you can't plot a Matlab function.
3. Comsol can't fiind any external Matlab function that I create.
I tried numerous things, including putting the function in the
default Matlab 2010a path, in the Comsol 4.0a directory,
etc. None of them worked.
Things that are expected but missing from the Matlab
function interface and the documentation are:
1. The path to a stored Matlab m-file with the function.
How does Comsol know where to look for it, or does
it follow the Matlab path tree as defined in Matlab? Is
it possible to define a path within Comsol independent
of Matlab (this would be preferable, since it wouldn't
require messing with an otherwise stable Matlab tree.)
2. Some information about restrictions on usage of such
a function, for example only allow return values of floating
point, and no arrays permitted. (see my comment above
about reaction rates.)
3. At least one worked example illustrating proper
usage would be very useful.
Anyone with experience successfully doing this?
Thanks!
Dave
external Matlab functions?
I am running Comsol 4.0a, and would like to be able to pass
parameters to a Matlab function, do some calculations, pass
the results back to Comsol and assign them to a variable. It
would also be really useful to be able to pass back and assign
an array of results to Comsol variables. An example of this
would be in the Chemical Reaction Engineering Module
where one might want to compute externally an array of
reaction coefficients for assignment to Comsol. Is this
possible?
I have no problem launching Live Link and exporting models
to Matlab. However, the procedures for defining and invoking
a Matlab function from within Comsol are unclear in the
documentation. The basic description is:
1. Right click Global Definitions, and then go to Functions=>Matlab
A MATLAB1 node is created.
2. Select the MATLAB1 node, and under Settings, enter in the required
information. This includes the Function name and Arguments. There
is a button for plotting the function, but it invokes an error message
saying you can't plot a Matlab function.
3. Comsol can't fiind any external Matlab function that I create.
I tried numerous things, including putting the function in the
default Matlab 2010a path, in the Comsol 4.0a directory,
etc. None of them worked.
Things that are expected but missing from the Matlab
function interface and the documentation are:
1. The path to a stored Matlab m-file with the function.
How does Comsol know where to look for it, or does
it follow the Matlab path tree as defined in Matlab? Is
it possible to define a path within Comsol independent
of Matlab (this would be preferable, since it wouldn't
require messing with an otherwise stable Matlab tree.)
2. Some information about restrictions on usage of such
a function, for example only allow return values of floating
point, and no arrays permitted. (see my comment above
about reaction rates.)
3. At least one worked example illustrating proper
usage would be very useful.
Anyone with experience successfully doing this?
Thanks!
Dave