Why do I receive the error "Index exceeds matrix dimensions." when I try to compile my file using the MEX function?

1 view (last 30 days)
I am trying to create a MEX-file.
I am trying to compile my code by issuing the following command at the MATLAB command prompt:
 
mex @myDirectory\myFile.c
When I issue this command, I receive the following error:
  ERROR: ??? Index exceeds matrix dimensions. Error in ==> mex>get_mex_opts at 351 arg = varargin{count}; Error in ==> mex at 225 mexname = get_mex_opts(varargin{:});
Why am I receiving this error?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 31 Jan 2017
You are receiving this error because "myDirectory" starts with an "@" symbol which causes the MEX function to interpret "myDirectory" as a script switch.
The "@" symbol is a MEX script switch which, when followed by a file name, tells the MEX function to include the contents of the text file as command line arguments to the mex script. For more information on MEX Script Switches, see the online documentation at:
To use the MEX function with directories that begin with "@", precede the directory name with ".\".
In the example that you have cited here, use the following syntax instead:
 
mex .\@myDirectory\myFile.c

More Answers (0)

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!