Simple logical conditional flag column
1 view (last 30 days)
Show older comments
david crowley
on 23 Nov 2021
Answered: david crowley
on 23 Nov 2021
I require help to develop some logic on the below data extract. I need the C2 column to toggle to '1' when C1 is '1'. Then, when C1 is '-1' the C2 column toggles to '0'. All rows in C2 between the C1 toggles (1 & -1) needs to turn to '1'.
Date C1 C2
'24-Dec-1999' 0 0
'31-Dec-1999' 1 0
'07-Jan-2000' 0 1
'14-Jan-2000' 0 1
'21-Jan-2000' 0 1
'28-Jan-2000' 0 1
'04-Feb-2000' -1 1
'11-Feb-2000' 0 0
'18-Feb-2000' 0 0
'25-Feb-2000' 0 0
0 Comments
Accepted Answer
More Answers (1)
See Also
Categories
Find more on Language Fundamentals 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!