Why am I getting an undefined function handle error when calling parfeval in MATLAB R2024b?

4 views (last 30 days)

I am encountering a "MATLAB:UndefinedFunction" error with the message, "Undefined function handle" when running a MATLAB script in conjunction with a SimBiology program in MATLAB R2024b. The program performs a set of model fits to experimental data by submitting each model fit to a cluster using "parfeval". The cluster consists of the host computer (running a MATLAB SimBiology Model Analyzer interface and runs the program) and five additional compute nodes. This issue only occurs after the SimBiology program has been run at least once with the parallel pool generated by the cluster. How can I resolve this error?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 21 Jul 2025
To resolve this issue, ensure that all helper functions called within the code are separated into different .M files. Next, pass all these files to the workers by calling the "addAttachedFiles" method in the entry point MATLAB code. 
For example:
p = parpool('YourCluster'); addAttachedFiles(p, ["function1.m", "function2.m", "function3.m", "function4.m", "function5.m", "function6.m", "function7.m"]);

More Answers (0)

Communities

More Answers in the  SimBiology Community

Categories

Find more on Perform Sensitivity Analysis in Help Center and File Exchange

Products


Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!