Error when compiling brainstorm

Although we can run simple script, it seems like MATLAB Runtime does not support script that calls custom classes.

I added a new paragraph to the documentation:

"In this configuration, the Matlab Runtime is not allowed to compile and execute .m scripts as a regular Matlab installation would. To work around this limitation, Brainstorm reads the script.m file and executes its contents with the Matlab eval function. Therefore this approach does not support the definition of functions or classes within the script.m. The compiled version of Brainstorm can only run code that can be executed from the Matlab Command Window. If you need more flexibility, you need to recompile a modified version of Brainstorm including your custom code (see below)."

https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting#Without_Matlab

Is there a way to work around this problem ?

Unfortunately not.
If you need additional classes or functions, you need to include them in the compilation of Brainstorm...