Include a file in a compiled app that can be modified by the user and accessed by the program

조회 수: 15(최근 30일)
I am compiling a program that has several options that need to be set by the end user. The 'options file' is a CSV file that MATLAB reads to set the various options within the program itself. This works fine when running the app via MATLAB; I can change a setting in the CSV file, and MATLAB reads the CSV file and applies the setting within the program.
However, when compiling an app, the CSV is swallowed up and incorporated into the executable. Although the app is able to read the contents of the CSV file as it was when compiled, it is no longer accessible to the end user, and hence, no changes to the options can be made.
How do I compile an app whilst still leaving specific files uncompiled, but available for the app to refer to?
  댓글 수: 1
David Barry
David Barry 2016년 12월 14일
  • How are you referencing the CSV location? Full path relative to a root?
  • Why not use a MAT file as it will be quicker?
  • Better still, why not use the MATLAB preferences to store preferences?

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

채택된 답변

Matt J Dunn
Matt J Dunn 2016년 12월 21일
I worked out a solution to this problem. By removing the CSV files from the MATLAB folder I can compile a 'broken' version of the app. I can manually add these files to the 'Files installed for the end user' section of the Compiler. Then, after installation, the user has to move the CSV file (or whatever you want to use) into the same folder as the app executable.

추가 답변(2개)

Walter Roberson
Walter Roberson 2016년 12월 14일
"How do I compile an app whilst still leaving specific files uncompiled, but available for the app to refer to?"
You cannot do that.
You need to decide on a location for the user-modified file relative to the user's directories, possibly by making use of environment variables; https://www.mathworks.com/matlabcentral/newsreader/view_thread/149027
You need to allow the file to be compiled in anyhow.
In your code, you need to build up that path and try to open that file using the fully-qualified path. If that fails, then try to open it without a path, to get the compiled-in version. (If that fails too, do whatever is appropriate, possibly complaining about corrupt installation.)
You might want to provide an interface to allow the user to modify the file, writing it into the location you decided on.

Image Analyst
Image Analyst 2016년 12월 15일
That's why I don't include such files in the compiled app, plus the fact that the deploytool does not let you install files anywhere you want, it requires them to be in the folder or subfolder of the app. So I use a third party installer to bundle up my files. Now I can put them wherever I want.

범주

Find more on MATLAB Compiler 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!

Translated by