How to make an input data file used by compiled code available for editing?

17 views (last 30 days)
I am compiling a set of functions which take an input file (ascii or .xlsx), use the data as inputs for a model, and then output the results to another file (ascii or .xlsx). When I compile the code, I include the output file in the list of "Files installed for your end user", and it outputs to the file.
However, the input file is read by the compiler as required for the functions to run, and is included in the "Files required for your application to run", and as a result seems to be compiled into the code, which means its not available for the end user to modify. This is probably a simple issue, but does anyone have recommendations on how to make the input file editable so end users can provide their own input files for a compiled Matlab function?
Graphically, the process should be like the following:
input_file (accessible to end user) ----> compiled_code (executed by end user) ----> output_file(accessible to end user)
However, compiling the code results in:
compiled_code_and_input_file ----> output_file.

Accepted Answer

Robert
Robert on 31 May 2017
Edited: Robert on 31 May 2017
And then, an answer presents itself! I pulled the input file out of the directory where the .m files were stored when it was compiled, and placed it elsewhere. This allowed me to remove the file from the list of "Files required for your application to run" section. Then I added the file (from its new location), to the "Files installed for your end user" section, and compiled the code.
The input file is loaded when the compiled code is installed, and I've checked that it is the file being read by the code by removing it (removing it causes the .exe to generate an error).
I have no idea why this worked.

More Answers (2)

Walter Roberson
Walter Roberson on 31 May 2017
Make a decision as to where the file must be stored relative to the user's directory structure. In your code, pull out the username and home directory and whatever else is necessary to figure out what the path would be to the current user. Build the name. Test to see if it exists; if it does then read from it. If it does not already exist, then read from your saved copy that you included with the application.

Robert
Robert on 31 May 2017
Edited: Robert on 31 May 2017
Hi, thanks for the response, unfortunately, this does not seem to resolve the issue. I am currently running the user-specific path in the compiled version (using isdeployed), so the path does not seem to be an issue.
The simplest thing to do would be to move the file from the "Files required" section to the "Files installed for the user" section, however, the application wont allow me to remove it (when I remove it, the application puts it back again). I can add it to the "Files installed for user" section, however, when the code runs, it uses the data that is compiled into the script rather than the added file. I've checked this by deleting the input file and running the .exe, and it runs correctly.
I will keep digging on the problem

Categories

Find more on Introduction to Installation and Licensing 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!