Calling External Functions From Within the Model
Use LiveLink™ for MATLAB® to call MATLAB functions from within the model — for instance, when working in the COMSOL Desktop. The procedure is different than implementing a model using a script because you do not need to run COMSOL with MATLAB.
Start COMSOL Multiphysics as a standalone application. The external MATLAB function needs to be defined in the COMSOL model so that a MATLAB process can automatically start when the function needs to be evaluated. The result of the function evaluation in MATLAB is then sent back to the COMSOL environment.
To run a MATLAB function, enable Allow external MATLAB® functions in the Preferences window; see Allowing External MATLAB Functions for more information.