Azzera filtri
Azzera filtri

Add resources to compile .m

7 visualizzazioni (ultimi 30 giorni)
Florian Segura
Florian Segura il 2 Dic 2019
Risposto: Nicolas B. il 2 Dic 2019
Here is my problem:
  • I have a pfile file.p, which call a data.mat file in .\resources\data.mat. I want to have a standalone application of that with .ctf file next to it. I use mcc to compile the both file:
mcc -W main:file -T compile:exe -v .\file.p -a '.\resources\data.mat'
  • But I have'nt found a way to make it work:
Error using load
'.\resources\data.mat' is not found in the current folder or on the MATLAB path, but exists in:
  • I can add manually a folder with the .mat file .\resources\data.mat next to my .exe, but is there a way to avoid that and "keep" a folder structure in the .exe ?
I use MATLAB 2017b with Windows 10. Matlab compiler of course.
after few test, this is working:
And this is not working:
But in my case, I have a pfile, so I can't modify the code. So I suppose that the data are called with a ".\".

Risposte (1)

Nicolas B.
Nicolas B. il 2 Dic 2019
Personnally, I try to always access the files which are encapsulated into my applications without the path.
My advice:
  1. Use MATLAB/Simulink Projekt to create your workspace with all files you need in the path
  2. Replace all your relative path in your code with direct access to file (e.g. load data.mat)
  3. Compile your app
  4. To check what looks like your workspace once you start the compiled app, check the content of this folder:
In this folder, you will find the exact workspace used by your app. You can then easily check that all files are included and what they have for path.


Scopri di più su MATLAB Compiler in Help Center e File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by