Thursday, June 29, 2017

[Matlab GUI] Set an absolute path for standalone application

When running a standalone application created by Matlab compiler, it needs to check if the code is running in deployed mode or Matlab mode because the path is changed depending on the mode.

Here is the code to check the running mode.

if isdeployed % Stand-alone mode.      
    [~, result] = system('path');
    currentpath = char(regexpi(result, 'Path=(.*?);', 'tokens', 'once'));
else % MATLAB mode.  
    currentpath = pwd;
end


No comments:

Post a Comment