Sign switching in a sequence
Mostrar comentarios más antiguos
I have a column vector for example,
A=[10; 30; 30; 40; 60; 70; 50; 50; 60; 20; 20]
What I want to do is count each time a number makes a transition from a smaller number to a large number, to count the numbers of times a number makes a transition from a larger number to a smaller number and the number of times the is no change in numbers.
Any help would be great thanks!
Respuesta aceptada
Más respuestas (1)
Azzi Abdelmalek
el 7 de Jun. de 2013
Editada: Azzi Abdelmalek
el 7 de Jun. de 2013
ii=histc(sign(diff(A)),[-1;0;1])
%ii(1) correspond to switch high-low
%ii(2) no switch
%ii(3) switch low-high
doc diff
doc sign
doc histc
1 comentario
olig
el 7 de Jun. de 2013
Categorías
Más información sobre Dynamic System Models en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!