Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

I am geting the "Subscript indices must either be real positive integers or logicals." error but I think that my subscript indices are real positive integers?

1 vue (au cours des 30 derniers jours)
Jessica jones
Jessica jones le 8 Jan 2013
Clôturé : MATLAB Answer Bot le 20 Août 2021
The line of code is
handles.PointLocs = uint32(BWloc);
% gets the time where the point is collected
handles.timeBW = handles.TIME(handles.PointLocs);
BWloc is a 855x1 double, and handles.TIME is a 28908x1 double. After being converted to uint32 handles.PointLocs is made up of numbers that are integers, real, and possitive. Thus I don't know why I am still getting the error
Subscript indices must either be real positive integers or logicals.
What am I missing?

Réponses (1)

Matt J
Matt J le 8 Jan 2013
Modifié(e) : Matt J le 8 Jan 2013
After being converted to uint32 handles.PointLocs is made up of numbers that are integers, real, and possitive.
The command
any(handles.PointLocs(:)<1)
can be used to check if you're right about that.
  4 commentaires
Image Analyst
Image Analyst le 8 Jan 2013
Try this instead, to find zeros or negatives:
badIndexes = find(handles.PointLocs(:)<1) % no semicolon
Matt J
Matt J le 9 Jan 2013
Modifié(e) : Matt J le 9 Jan 2013
If I understand the what the equation does it just tell you that handles.PointLocs is not the same as a set that contains all the values from 1 to it's maximum value?
SETDIFF removes all values in the set 1:max from PointLocs and tells you whatever is left over. There should be nothing left over if your indexing is good because the only legitimate indices are the ones belonging to 1:max.
So, both tests I've proposed confirm that you have bad index values. In particular the first test confirms that some of them are zeros. Possibly you're doing 0-based indexing by mistake, forgetting that this is MATLAB abd not C\C++, and need to add +1 to convert them to 1-based indices.

Cette question est clôturée.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by