Expanding compiled app functionality by external p-files

Hello,
I am working on an application written in App Designer in MATLAB 2022a. The application is a simple UI in which the user 1.) selects a data file to process, 2.) selects a script that defines a certain process to run on the data, and 3.) pushes a 'Run Now' button that will call "process(file)" and generate output (in the form of MAT files and SQLite files) that are created in the data file directory. The app is intended to be compiled into an executable using the MATLAB compiler.
I hoped that I could structure the code such that the user could 'install' additional process functions to expand the functionality of the app without the need for a complete uninstall/reinstall of the application (bug fixes, user-specific processes, etc). My vision was to accomplish this through calling an 'Install New Process' callback that would basically copy a set of p-files to an application-specific folder under ProgramData (e.g. C:\ProgramData\MyApp\Processes) and add the Program Data subfolder to the MATLAB path using addpath( )
In development, I have been doing this by copying some m-files to a folder within Program Data (C:\ProgramData\MyApp\Processes) and calling the following code during the MyAppStartUpFcn:
addpath(fullfile(getenv('PROGRAMDATA'),'MyApp\Processes'))
The app then calls the something similar to the following to get a list of functions within the processes folder, and populates a uidropdown with the results:
processes = {dir('PROGRAMDATA'),'MyApp\Processes\*.m').name};
app.UIDropDown.Items = processes;
Once the user presses the 'Run Now' button, the code converts the currrent dropdown value to a function handle and calls the function on the selected data file:
fh = str2func(app.UIDropDown.Value);
fh(selectedDataFile);
While this approach has worked fine during development, I am seeing various posts in the forums (see refs) that indicate that modifying the path via addpath( ), cd( ), etc. is not possible when in a compiled application.
Is there some work around to accomplish 'installing new functions' in a way that the app can see them post-install?
Note: I have not yet attempted accessing externally located functions from a compiled app, as we only have a specific PC with the compiler license. I just wanted to get some more clarification before attempting based on what I have seen in the forums.
Refs:
https://www.fieldtriptoolbox.org/faq/how_to_compile_matlab_code_into_stand-alone_executables/#:~:text=The%20compiled%20application%20includes%20all,to%20extend%20the%20search%20path.

Antworten (1)

Steven Lord
Steven Lord am 5 Apr. 2023

0 Stimmen

From the documentation: "MATLAB Runtime only works on MATLAB code that was encrypted when the deployable archive was built. Any function or process that dynamically generates new MATLAB code will not work against MATLAB Runtime."

2 Kommentare

Would it be possible to compile the additional functions as a DLL, and call the functions through that?
I don't know the answer to that question. You might want to contact Technical Support directly using the Contact Support link under the Get Support heading at the end of this page and determine if there's a way (and if so what's the best way) to satisfy your requirements for how to extend your app functionality as you described.

Melden Sie sich an, um zu kommentieren.

Kategorien

Produkte

Version

R2022a

Gefragt:

am 5 Apr. 2023

Kommentiert:

am 6 Apr. 2023

Community Treasure Hunt

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

Start Hunting!

Translated by