Azzera filtri
Azzera filtri

Adding folders to MATLAB search path when installing app created using App Designer

31 visualizzazioni (ultimi 30 giorni)
I have created an application using app designer. The application requires access to some MATLAB functions which are inside subdirectories. I have included those subdirectories in the project used for packaging the app. When the app is installed, those directories do appear in app installation area. However, they are not on MATLAB search path.
I know you can specify which directories to add to path when packaging a toolbox. I was wondering if there is a way to do it for apps.
Thank you,
  3 Commenti
Gary Burton-Wilcock
Gary Burton-Wilcock il 4 Giu 2020
Hi - I have the same problem. I have an app which uses external Matlab functions. It works fine if I run it within App Designer if I use the 'addpath' command in the apps startupFcn to point at the folder containing the external functions. If I don't add the path I get an unknown function error as you would expect. The 'addpath' does not work if the app is compiled and then installed as a standalone app. In fact if you show the contents of 'path' in a text edit box you get nothing with the stanadalone app. The app GUI runs but nothing happens when one of the external functions is called - not even an error, just nothing.
I noticed when I was testing in App Designer that when you run an app the folder holding the app is added to the matlab path - along with some other local paths. I tried moving the app so that it was in the same folder as the external functions and packaged the whole lot from there. The standalone app still didn't find the external functions although it did show some output from the path command, but just the usual matlab folders you see if you run path after opening Matlab.
The only solution I can see is to bring the functions in to the app itself. I have other apps that work fine in this way. The problem in this case is that the external functions are called by another program written in C# and act as a bridge between the Matlab gui and the C#. That works fine so long as I only work in App Designer! But I need to launch it as a standalone app.
Any help gratefully received.
Gary Burton-Wilcock
Gary Burton-Wilcock il 11 Giu 2020
Modificato: Gary Burton-Wilcock il 11 Giu 2020
I did a bit more digging on this and found that when Matlab packages and installs the standalone app it creates compiled versions of "files required for your application to run". These files have the same names as the originals so my guess is that if you try to point your mlapp at the original files using the addpath command it gets confused - although it doesn't tell you so. The compiled files are in C:\Users\$userName\AppData\Local\Temp\jl308\mcrCache9.8\$app name stuff. When the app runs it uses these files.
If that's right it means that a mlapp can't use an external library of functions that can be shared with another app (C# or otherwise). If the library functions change then the mlapp needs to be recomiled and re-installed.

Accedi per commentare.

Risposte (0)


Scopri di più su Develop Apps Using App Designer 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