MATLAB: Does the deployed application fail if I use Icons provided by MATLAB in the code

compilerdeployediconsMATLABMATLAB Compilermcrruntime

I have a simple MATLAB code which uses the Icons provided by MATLAB. The icons provided by MATLAB are located at following location in my MATLAB:
<matlabroot>\toolbox\matlab\icons 
Hence I used the same path and wrote the following code:
function test
    imread([matlabroot,'\toolbox\matlab\icons\pin_icon.gif']);
end
I observed that my code worked fine in base MATLAB.  However, when I created a standalone application from the same code and I tried to run it on deployment machine, the standalone application failed with following error message:
  ERROR: Error using imread File "C:\Program Files\MATLAB\MATLAB Runtime\v901\toolbox\matlab\icons\pin_icon.gif" does not exist. Error in test12 (line 2) MATLAB:imagesci:imread:fileDoesNotExist
On further investigation I noticed that the "icons" folder was missing at following location "<matlabroot>\toolbox\matlab\" in MATLAB Compiler Runtime.
Why does this application fail and why isn't there "icons" folder at "<matlabroot>\toolbox\matlab\" in MATLAB Compiler Runtime?

Best Answer

The reason behind this issue is "Icons" folder is present in MATLAB Compiler Runtime if compared to base MATLAB installation. The folder is located at following location:
<matlabroot>/mcr/toolbox/matlab/icons
As a workaround for this issue you can use following methods:
1. The "Icons" folder is always present in the MATLAB search path hence it is redundant to use complete path for accessing these icons hence instead of using "imread([matlabroot,'\toolbox\matlab\icons\pin_icon.gif']);", we can use following command:
>> imread('pin_icon.gif');
2. If for some reason you have multiple files with same name and you need to use absolute path to access the icon, please use following syntax:
>> imread(fullfile(toolboxdir('matlab'), 'icons', 'pin_icon.gif'));