why the 'mphload' can work in .m doesn't work in .exe? (error: undefined function 'string2char')

19 views (last 30 days)
this code and the function work well in a .m file, but don't work in a matlab complier made .exe file. error window says undefined function 'string2char' for 'char' type input arguments. which is confusing.
% string(file_s0);
'fpath' has the right content, I load a .mat file with it.
I'm sure MATLAB has been connected to a COMSOL Multiphysics Server before this code. I use the same .exe to start the COMSOL server and connect it to MATLAB.
I try to turn 'file_s0' into string before pass it to 'mphload' with code "string(file_s0); " and "cellstr(file_s0);" doesn't solve the promblem, same error occured.
tryed "char(file_s0);" before mphload, make no difference.
someone meet 'Undefined function 'mphload' for input arguments of type 'char'. and re-installing the comsol and matlab solve the problem. Maybe I should try this today.
Yinying Wang
Yinying Wang on 17 May 2020
don't know how to tag this question as "solved" so I just write an answer myself and accept it. Hope it wouldn't break rules...

Sign in to comment.

Accepted Answer

Yinying Wang
Yinying Wang on 17 May 2020
problem solved.
I add all m files and p files in fold 'COMSOL53a\Multiphysics\mli' in matlab compiler, then it works.
  1 Comment
dongyan zhang
dongyan zhang on 30 Mar 2021
Hi !I meet the same problem,but I add all m files and p files ,it doesn't work.And my codes are here.

Sign in to comment.

More Answers (0)


Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!