How can a logical vector be converted to a numeric vector in which the values represent the number of zeros between ones?
Show older comments
I am searching for a simple way to convert a logical vector, to a vector in which the values represent the total number scalars between ones, and including the first 1 in the list. Essentially converting x to y where:
x = [1;1;1;0;0;1;0;1];
y = [1;1;3;3;3;2;2;1];
Any suggestions? Thanks!
RTT
1 Comment
Walter Roberson
on 10 Nov 2016
Please explain further how you get that y from that x ?
Accepted Answer
More Answers (1)
Robert
on 7 Dec 2016
0 votes
Categories
Find more on Creating and Concatenating Matrices 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!