Use MATLAB® Function to define the model property. The function can either be declared within the model object or called at the MATLAB prompt.
LiveLink™ for MATLAB® enables you to declare a MATLAB M-function directly from within the COMSOL Multiphysics
model object. This is typically the case if you want to call a MATLAB M-function from the COMSOL Desktop. The function being declared within the model object accepts any parameter, variable, or expression arguments defined in the COMSOL model object. However, to use a variable defined at the MATLAB prompt, the variable has to be transferred first in the COMSOL model as a parameter, for example (see how to set a MATLAB variable in the COMSOL model in
The Set and SetIndex Methods).
where myfun() is an M-function defined in MATLAB.
The function is called only when the command is executed at the MATLAB prompt. The argument of the function <arg> called can be MATLAB variables. To include an expression value from the model object, first extract it at the MATLAB prompt, as described in
Extracting Results.
The function myfun() accepts the model object
model as an input argument as any MATLAB variable.