Index exceeds matrix dimension

I have this error and I do not understand why. Here's the code:
>> I1_inliers
I1_inliers =
608×1 SURFPoints array with properties:
Scale: [1×608 single]
SignOfLaplacian: [1×608 int8]
Orientation: [1×608 single]
Location: [608×2 single]
Metric: [1×608 single]
Count: 608
>> I1_inliers(1)
ans =
SURFPoints with properties:
Scale: 2.8000
SignOfLaplacian: 1
Orientation: 0.3424
Location: [753.3676 999.5223]
Metric: 1.8129e+04
Count: 1
>> I1_inliers(2)
Index exceeds matrix dimensions.
I have the same error for every index but 1.

5 comentarios

KSSV
KSSV el 12 de Jun. de 2017
what is length(I1_inliers)??
John D'Errico
John D'Errico el 12 de Jun. de 2017
It looks like someone has written a SURFPoints class, but I might look at how SURFPoints/subsref was implemented.
Adam
Adam el 12 de Jun. de 2017
There's definitely something non-standard in whatever SURFPoints is. When I display an array of custom class objects I just get something like this:
K>> wavelets
wavelets =
1×13 RickerWaveletHz array with properties:
frequency
sampleRate
phase
times
centralFrequency
amplitudes
frequencies
spectrum
which gives no information on the size of arrays within each object (obviously there is no guarantee of fixed size for these arrays across objects). This alone can be changed by giving a custom disp function, but if you are creating custom disp functions then you are likely doing other things as well as John D'Errico suggests.
About length
>> length(I1_inliers)
Function 'subsindex' is not defined for values of class 'SURFPoints'.
SURFPoints is a class of the computer vision toolbox. They represent a set of features inside images.
Adam
Adam el 12 de Jun. de 2017
Editada: Adam el 12 de Jun. de 2017
I suspect that it is actually a scalar with an overloaded size function, looking at it again. I have done that myself once or twice on a class (and usually regretted it afterwards because it confuses me too much).
The size function can be overloaded so that in a case like yours where the object contains a lot of arrays all of the same size the 'size' function is programmed to return that size which over-rides the usual size function which would return [1 1] as the size.
So even though it claims to be a 608x1 array it actually isn't and is just a scalar object containing arrays of length 608.
You would need to access the individual properties with indexing in that case.
I don't have the Computer Vision Toolbox though so I am just surmising based on the symptoms you describe and what is shown when you display the object

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Etiquetas

Preguntada:

el 12 de Jun. de 2017

Editada:

el 12 de Jun. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by