Can I Change a Function in a Packaged Executable?

I would like to be able to regularly update or change a function in a packaged app. Can I exclude the function from the dependencies, and call this function inside the app? This would save me from having to reinstall the entire app.

 Accepted Answer

Unfortunately, you cannot include an uncompiled function in the application. The MATLAB Compiler requires all dependencies to be included during compiling to ensure that the end user has all the necessary components installed.
One workaround is to split the application into multiple compiled applications. The application with the function can then be called from the main application. The following code example illustrates this process:
standalone1.m – The code takes an input number and adds 1 to it
function result = standalone1(inputNumber)
    result =  str2num(inputNumber) + 1;
    disp(result);
end
standalone2.m – Calls standalone1.m and passes a value to it
number = 5;
system(['./standalone1 ' num2str(number)]);
Both standalone applications can be compiled separately. Once compiled, the executables will need to be in the same folder, or the path to standalone1.m in standalone2.m will need to reflect the location of the file. The standalone1.m file can be changed and recompiled separately from standalone2.m to update its functionality. 
Alternatively, the MATLAB Compiler SDK may help with reducing install time for the standalone application, by generating shared libraries. The following link provides information on it:

More Answers (0)

Categories

Products

Release

R2022b

Community Treasure Hunt

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

Start Hunting!