MATLAB: Index in position 1 exceeds array bounds (must not exceed 4079). how to rectify this error

exceeds array bounds

Index in position 1 exceeds array bounds (must not exceed 4079).
Error in outex_14>cal_AP (line 200) tests = CLBP_SMCH(testIDs,:);
Error in outex_14 (line 42) AP = cal_AP(Hist,trainIDs, trainClassIDs,testIDs, testClassIDs) This is the error i am getting when i am running the code. Ihave attached my code with this? how to make changes to match the size?

Best Answer

You are passing Hist and testIDs to your cal_AP function. In that function your try to access Hist(tesIDs).
Hist has 4079 rows (set by picnum early in your code), testIDs does not have this limitation and rather grows as long as there are images in your file. If there are more than 4079 you will get that error.