I wanted to know if there is a way to get the average duration of a state. Attached is a .mat data file with 3 different states indicated with 1, 2 and 3. I am trying to find out the average duration for each of these, if the column is the time(1000 sec) then what's the average duration for each of them, or how many consecutive states are there for specified amount of seconds: 1s in 1sec,1s in 2 sec, 1s in 4 sec,.. 1s in 256 sec,..etc. So if there was a consecutive 1,1,1,1 then that would be one round added to the 4 seconds.
I assumed I need to use histogram bin counts but I don't know how to write the code myself. Or just finding out how many times times it switches from state 1 to state 3.
Best Answer