I have the following directory structure:
main
+model
run.m
+options
opt.m
main.m
and so forth.
I have a function under +model
directory called run
that depends on some functions in the +options
directory, such that my main.m
script under directory main
calls model.run()
and the function run
calls some options.opt()
.
I want to generate a MEX file of model.run()
, so I run the coder
from MATLAB command prompt, and on the first screen, where I enter the function name to generate code model.run
, the coder simply displays the error:
This file is shadowed by C:\....\+model\run.m
I already tried adding the main
directory to the path, but it didn't work.
model.run()
in this scenario?MATLAB version: '9.4.0.813654 (R2018a)'
Generating code directly from a function in a package is unfortunately not supported in MATLAB Coder as of MATLAB R2019a. We've made an internal note of your request so we can look at lifting that limitation in the future.
The workaround right now is to add a wrapper function outside of a package that calls model.run
and use that as your entry-point function with Coder. You could then move the resulting MEX file to your +model
directory so that model.run
calls the generated MEX in the rest of your code.