0

I am trying to deploy an application which are dependent on specific data input files in the form of .m files.

I know how to bundle all of the files "freezing" them within the compilation: like so mcc -m file.m -a path_to_data*.m.

However, I was wondering if it is possible to just add the path to the data folder into the deployment project and then have the data files within the folder being interchangeable (i.e. being added to the MATLAB path upon execution and not freezed during compilation). The advantage of this would be that the application could still be used if some data files needed to be changed without having to recompile everything.

What would be the best way to do this? Is it possible with the MATLAB compiler? ps. I am working on a unix system

  • 1
    M-files are not data files. If you use M-files for data you're doing it wrong (it's not efficient and not flexible). Use MAT-files or any alternative format like CSV, TIFF, GIS or whatever is suitable for your data type. Your program can read such files from outside the bundle. Provide your data files separately from the bundle, you'll be able to replace them at any time. – Cris Luengo Jul 30 '19 at 14:27
  • Thank you for the comment. They are Simulink parameter settings stored in m files. Let's think of them as scripts instead (the wording data might be confusing). Do you know if it is possible to only put the path as input and then in the main script under isdeployed load the files from that path? – user9015897 Jul 30 '19 at 15:23
  • You cannot execute arbitrary M-files within a compiled application, as far as I know. I do remember using `eval` in a compiled application at some point, so you might be able to read in the M-file as a text file and execute its statements. Not sure. I'm not familiar with Simulink. Are there no other ways to store parameter settings? – Cris Luengo Jul 30 '19 at 15:25
  • Yes thank you I know that you can read an m file, line by line and execute each line with the eval() function. So that works, my question was more related to the path where they are located. If it is possible to add a subfolder path to the working directory since 'addpath' is not supported in the deploytool – user9015897 Jul 30 '19 at 15:38
  • It needs to be an external file, outside of the compiled application. If you read the M-file as a text file and use `eval` on each line, then you can simply specify the full path to the file when reading it. – Cris Luengo Jul 30 '19 at 18:20

0 Answers0