MATLAB: How to make a system able to find a file under the MATLAB root directory

addpathfilefoundmatlabrootnotrootsystemwhich

I am trying to use a custom CGT (Code Generation Template) in MATLAB, however, MATLAB does not seem to have it in the path.
I have created a directory "sert" in "matlabroot\rtw\c\" and placed a copy of "matlabroot\toolbox\rtw\targets\ecoder\ert_code_template.cgt" there with a name "sert_code_template.cgt".
Then I ran "addpath" command as follows:
addpath([matlabroot '\rtw\c\sert'])
However, when I run "which sert_code_template", it does not find this file. What is the issue here?

Best Answer

Folders under matlabroot are by default "frozen", meaning that any changes to these folders on the path will not be picked up by MATLAB automatically.
If this file has to be placed under matlabroot, you can try
>> rehash toolboxcache
or
>> fschange "foldername"; rehash;
after placing the file into a folder that is under matlabroot (and also on path).
Then, the "which" command should be able to find the file.