Allowing External MATLAB Functions
To run MATLAB functions you need to allow external processes in the security preferences.
In the COMSOL Desktop go to the Preferences and select Security, locate the General section. To permanently enable an external MATLAB function, in the list Allow external MATLAB® functions select Yes. To enable an external MATLAB function only once, set the list Allow external MATLAB® functions to Ask. Using the latter option, you will be asked to enable external functions when the function is run.
In the COMSOL Server™, you need to connect as administrator then go to Administration>Preferences, in the Security section select Allow external MATLAB® functions. Then click Save.
Allowing External Processes in the Command Line
Add the flag -allowexternalmatlab on to the COMSOL startup command to permit external MATLAB functions to run.