Sign switching in a sequence
Ältere Kommentare anzeigen
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!
Akzeptierte Antwort
Weitere Antworten (1)
Azzi Abdelmalek
am 7 Jun. 2013
Bearbeitet: Azzi Abdelmalek
am 7 Jun. 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 Kommentar
olig
am 7 Jun. 2013
Kategorien
Mehr zu Dynamic System Models finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!