Error with mex file ... ....Index exceeds matrix dimensions. Index value 3 exceeds valid range [1-2] of array gesgroup.

1 view (last 30 days)
I have a function file to mex file. But it is giving error when running the mex file. Following is the code.
In the code I have initialised 3 vectors named group,horgroup,gesgroup and declared gesgroup as varsize.
group = zeros(1,2);
horgroup = zeros(1,2);
gesgroup = zeros(1,2);
coder.varsize('gesgroup');
in few lines group and horgroup are calculated as arrays of size (1 * 2) say group = [1 2] and horgroup = [3 4] later i need to merge group and horgroup into gesgroup using
gesgroup = [group, horgroup];
gesgroup(gesgroup==0) = NaN;
this code is not giving any error while generating a mex file but when I am running the mex file its giving error in above two lines, saying "Index exceeds matrix dimensions. Index value 3 exceeds valid range [1-2] of array gesgroup"
Let me know if I need to change anything in the code and generate the mex file again.

Answers (0)

Community Treasure Hunt

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

Start Hunting!