How Can I count the ascending runs in array ?
Show older comments
if I have an array such as
x=[1 2 3 2 1 2 4 5]
I would generate a binary array for binary search
binaryarray= [1 1 1 0 0 1 1 1]
in binaryarry i would sign 1 along with ascending runs while 0 along with descending runs.
Answers (1)
As KSSV wrote, you might find diff useful:
>> y = y([1,1:end])
y =
1 1 1 0 0 1 1 1
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!