Borrar filtros
Borrar filtros

How to detect a data value change in matlab

3 visualizaciones (últimos 30 días)
A-Rod
A-Rod el 11 de Jun. de 2024
Comentada: Voss el 13 de Jun. de 2024
looking for yur help one more time.
I have data that is constanly hanging, here I share one portion of it
I'm trying to create a variable/falg that helps me to identify when there is a change, somethinng like this:
DATA variable/flag
0 -----> matlab code -----> 0
0 0
0 0
0.1224 1
0.1219 1
0.1199 1
0.1199 0
0.1199 0
0.1175 1
0.1175 0
0.1175 0
0.1175 0
0.1300 1
0.1300 0
0.1200 1
DATA values can change any time, keep same value for different periods of time, and either increase, decrease or change to positive or negative side.
I don't have much experience with mat lab so any feedback will be highly appreciated.
thanks

Respuesta aceptada

Voss
Voss el 11 de Jun. de 2024
Editada: Voss el 11 de Jun. de 2024
DATA = [
0
0
0
0.1224
0.1219
0.1199
0.1199
0.1199
0.1175
0.1175
0.1175
0.1175
0.1300
0.1300
0.1200
];
is_change = [false; diff(DATA) ~= 0]
is_change = 15x1 logical array
0 0 0 1 1 1 0 0 1 0 0 0 1 0 1
% a table for viewing is_change alongside DATA
result = table(DATA,is_change)
result = 15x2 table
DATA is_change ______ _________ 0 false 0 false 0 false 0.1224 true 0.1219 true 0.1199 true 0.1199 false 0.1199 false 0.1175 true 0.1175 false 0.1175 false 0.1175 false 0.13 true 0.13 false 0.12 true
  6 comentarios
A-Rod
A-Rod el 13 de Jun. de 2024
thank you so much!
Voss
Voss el 13 de Jun. de 2024
You're welcome!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by