I have a Simulink model, the purpose of which is automated code generation.
My model uses S-functions (developed by another party), some of which have hard-coded assumptions about the path. For instance, several external data files are needed, which are referenced in one of the S-functions via a relative path like so:
This makes it necessary to set MATLAB's current working directory to a specific path before the model can be run.
I can automatically check and set the correct path via model callback functions. However, all model callback functions only seem to be related to the simulation process, not the build process. That means that I can run the model irrespective of what directory I'm in, but when I try to build the model, it always fails unless I manually navigate MATLAB back to the correct build directory.
Needless to say, that's quite annoying. So I was wondering if there is something like a "preBuildFcn" callback function, a function that is run before starting the build process? Any other solution (that does not involve modifying the S-function) is also very welcome.
My MATLAB/Simulink version is R2010a/7.5. I've already tried using RTW hook files, but when changing the path in the "entry" hook, I get the error:
"Warning: During the 'entry' hook call to 'grt_make_rtw_hook', pwd was changed to <new dir>. Changing directories is not allowed. The pwd will be reset to <previous dir>"
Note also that
is not available in R2010a.
I've been on a wild goose chase for the past 2 days now, without satisfying results. Is this at all possible in R2010a?