MATLAB Coder generated MEX file throws an error that "Index exceeds matrix dimensions" although the code runs in MATLAB without error
Show older comments
I'm trying to use MATLAB Coder to generate C/C++ code for my MATLAB code. However, when I try to execute the MEX file generated by MATLAB Coder, it throws an error that for a specific variable that the index exceeds matrix dimensions:
>> myCode_mex
Index exceeds matrix dimensions. The array 'A' is empty and therefore has no valid indices.
The error stack points to the following MATLAB source code where I perform array extension:
n = length(A);
if n < buffSize
A(n+1) = data;
The same code however runs in MATLAB without any issues. Why does this happen?
Accepted Answer
More Answers (0)
Categories
Find more on Algorithm Design Basics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!