MATLAB config file that loads variables at runtime

I would like to have a configuration file that acts similarly to a .config file that you would find in a C# program. Meaning I would like the variables in the config file to load into the application at runtime. I'm using the Application Compiler app to build the executable. I have tried having a text file with my config variables that is read at the beginning of the program, but it seems that these are only read when the application is compiled. I would like to compile/build the app only once, and have it read in the variables each time it runs. Is there a way for this to work within MATLAB?

 채택된 답변

Voss
Voss 2024년 6월 4일

0 개 추천

Use the app's startupFcn.

댓글 수: 3

This isn't quite what I'm looking for either... I don't expect to change the configuration every time I run the app. For example, one of the configuration items is to choose an sql server to store data. I would switch this between the test and production server pretty rarely, but still need the option. Since I'm making this app for others to use, I wouldn't want to require them to enter in all the configuration items every time they run the script. Any other ideas? It almost seems like the best solution is to just convert it to a C/C++ project.
I was thinking more like what you described in the question: "having a text file with my config variables that is read at the beginning of the program"
I wasn't thinking anything about changing the configuration or the user having to enter anything.
I see now. I had focused on the "Input arguments" component to the startupFcn in the documentation. Thanks!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

질문:

2024년 6월 4일

댓글:

2024년 6월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by