MATLAB: Unable to add S-function to MATLAB path when using “addpath”

addpathpwds-functionsimulink

I am experiencing an unusual issue where Simulink can't find a compiled S-Function, even when the folder that the function is located in is on the MATLAB path. I see an error saying "Double2Str.c cannot be found" or the like.
The commands I'm using to add the required folders to the MATLAB path are as follows :
addpath(genpath('apps/examples'));
addpath('lib');
addpath(genpath('robots'));

Best Answer

The commands you listed will not add the 'examples' folder located under 'apps' to the MATLAB path. This is because MATLAB R2016a does not implicitly add the path of the present working directory to the string arguments in "addpath", especially when you're trying to add subfolders. The commands you can use instead are as follows:
addpath(genpath([pwd '/apps/examples']));
addpath([pwd '/lib']);
addpath(genpath([pwd '/robots']));
Please note that in MATLAB R2016b, "addpath" implicitly adds the path of the present working directory. Therefore, the original commands would work in MATLAB R2016b.