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

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.
cd(fpath);
file_s0=fullfile(fpath,'\model.mph');
% string(file_s0);
models=mphload(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.

댓글 수: 3

update:
re-installed COMSOL, nothing changes.
maybe it's because matlab compiler doesn't support The Symbolic Toolbox functions, add that in tags.
problem solved.
I add all m files and p files in fold 'COMSOL53a\Multiphysics\mli' in matlab compiler, then it works.
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...

댓글을 달려면 로그인하십시오.

 채택된 답변

Yinying Wang
Yinying Wang 2020년 5월 17일
problem solved.
I add all m files and p files in fold 'COMSOL53a\Multiphysics\mli' in matlab compiler, then it works.

댓글 수: 1

Hi !I meet the same problem,but I add all m files and p files ,it doesn't work.And my codes are here.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 External Language Interfaces에 대해 자세히 알아보기

질문:

2020년 5월 14일

댓글:

2021년 3월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by