Effacer les filtres
Effacer les filtres

Read vector until last value, or NANs start

6 vues (au cours des 30 derniers jours)
David Pesetsky
David Pesetsky le 8 Juil 2018
Commenté : David Pesetsky le 8 Juil 2018
I have a vector array with an unknown number of entries. Either it will end nicely with the last entry being a number, or nans will start populating. I just need the index of the last actual number, not knowing if there's a next entry, or if the next is a nan.
Can you help?
Thanks!

Réponse acceptée

Walter Roberson
Walter Roberson le 8 Juil 2018
lastidx = find(isnan(YourVector),1) - 1;
if isempty(lastidx); lastidx = length(YourVector); end
  1 commentaire
David Pesetsky
David Pesetsky le 8 Juil 2018
Always solving problems! Thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by