count number with continuous numbers of 1's ?
1 回表示 (過去 30 日間)
古いコメントを表示
I had a matrix A=[0 0 1 1 1 1 0 0 0 1 1 0 0 1 0 0 1 0 0 0 1 1 1 0 0] like this , now I want a matrix B in which B(3)=1,next B(10)=1,B(14)=1 and similarly B(17)=1,B(21)=1 and rest are zeros means B gets value 1 when A first get 1.
0 件のコメント
採用された回答
Stephen23
2018 年 8 月 31 日
>> B = [0,diff(A)>0]
B =
0 0 1 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!