Capone
Capone

Reputation: 15

How to add user created .mat files to the search path after compilation

How can I allow user to add additional dependenies after the source code was compiled with mcc.

I was thinking about an empty folder next to the executable, where the users can add the needed .mat-files, but I can't add the folder path to my executable (since addpath is not allowed in deployed applications).

Any ideas?

Upvotes: 0

Views: 152

Answers (1)

matlabgui
matlabgui

Reputation: 5672

This answer assumes that your code can be customised by data contained in one or more .mat files at runtime.

You can point your code to look at a folder where the optional .mat file(s) would be located.

For example in the users home folder with a sub folder being the name of your application (or in the local app data) or whereever...

If you want it in a sub folder where the exe is, you can do this as well, you find the exe path using (on windows):

[status, result] = system('path');
installpath = char(regexpi(result, 'Path=(.*?);', 'tokens', 'once'));
fprintf ( 'The exe install path is "%s"\n', installpath );

Then your code looks to load for example:

file2load = fullfile ( installpath, 'subFolder', 'runtimeCustomisation.mat' )
if exist ( file2load, 'file' ) == 2
  "doSomething with the file"
end

Or something like that.

Recall that this is for dependencies which are .mat files only.

Upvotes: 0

Related Questions