Borrar filtros
Borrar filtros

find observations with nonconsecutive numbers

8 visualizaciones (últimos 30 días)
wesso Dadoyan
wesso Dadoyan el 8 de Jul. de 2017
Respondida: Walter Roberson el 8 de Jul. de 2017
A=[55; 56; 57; 58; 26; 27; 28]
I want to find the observations in A where the two consecutive observations are not equal. In this case it should be the 5th observation since 26~=58. How can I do that elegantly?

Respuesta aceptada

Walter Roberson
Walter Roberson el 8 de Jul. de 2017
find(diff(A) ~= 1) + 1

Más respuestas (1)

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH el 8 de Jul. de 2017
like this:
A=[55; 56; 57; 58; 26; 27; 28];
observations=A([1; diff(A)]~=1);
  2 comentarios
wesso Dadoyan
wesso Dadoyan el 8 de Jul. de 2017
these codes are giving 26 instead of 5. I don't want the value but rather the row number.
JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH el 8 de Jul. de 2017
A=[55; 56; 57; 58; 26; 27; 28];
observations=find([1; diff(A)]~=1);

Iniciar sesión para comentar.

Categorías

Más información sobre Discrete Data Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by