How to remove repeated values mantaining the first one from an array ?
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
I have something like:
10000111111111011011100000111011000111111011000000010101011111111....
how to:
00000100000000010010000000100010000100000010000000000000010000000....
The second repetition makes the beggining of a series.
0 件のコメント
回答 (2 件)
Sean de Wolski
2014 年 12 月 8 日
abs(diff('0000111001111101101'))
1 件のコメント
Guillaume
2014 年 12 月 8 日
Hum, it looks like the OP only wants the transitions from 0 to 1 (which would be diff(x) > 0) but only when there's more than one consecutive 1 (which is not as simple unfortunately).
Guillaume
2014 年 12 月 8 日
s = '10000111111111011011100000111011000111111011000000010101011111111'
o = char('0' + ([0 diff(s) > 0] & [~diff(s) 0]))
0 件のコメント
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!