HOW TO REMOVE "MATRIX INDEX IS OUT OF RANGE FOR DELETION"?

3 views (last 30 days)
I AM WORKING ON SURF BASED PROJECT. I AM GETTING THIS ERROR. PLEASE HELP. SCREENSHOT AND THE CODE IS ATTACHED.

Answers (1)

Walter Roberson
Walter Roberson on 17 May 2015
What very strange code. You are starting with a vector of copies of true(), and are removing certain elements of it. The result is, of course, just going to be a shorter vector of copies of true(). You then use that shorter vector of copies of true() as a logical index into an array; the result would be the same as taking the first N entries where N is the length() of the matrix. What is the length? The original length minus the length of the unique indices of the elements that were removed. Which could be written as
1 : (size(features2,1) - length(unique(IndexPairs(:,2)))
In the case where IndexPairs(:,2) contains distinct entries, that could be simplified to
1 : (size(feature2,1) - size(IndexPairs,1))
The entire bit looks fishy to me, as if the wrong items are being retrieved; it would make sense to me if instead of deleting elements out of the vector that was assigned true(), that the elements were instead set to false().
Anyhow, you would get the error message you did if some value in the subscripts you were using for deletion was non-positive or exceeded the size of the matrix.

Community Treasure Hunt

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

Start Hunting!