sum only consecutive 1's in matrix
이전 댓글 표시
I have a matrix of data where I want to go down each column in the matrix, and sum the occurences where 1's occur consectively. E.g. if I have
1
0
1
1
0
1
1
I want this to be recorded as 1,2,2 as the groups of 1's are separated by 0's. I want this data to be stored in a new matrix where the sum data for each column is stored in a column (in the same format as the orignal data).
Is this possible?
채택된 답변
추가 답변 (1개)
Matt J
2021년 10월 20일
See,
Tools for Processing Consecutive Repetitions in Vectors
[~,~,runlengths]=groupLims(groupTrue(particleNotMoved),1)
카테고리
도움말 센터 및 File Exchange에서 Array Geometries and Analysis에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!