Suppose, I have a variable, a.
a={ 18 5 1 3 14 2 1 2 4 2 5 9 2 1 5 7 1 5 6 7 3 3 6 1 3 7 6 5 16 6 6 3 5 3 6 6};
Based on column 3 value, I would like to check whether the values in COLUMN 4 are contiguous or not. The eg below is elaborated to clarify my goal.
Column 3 contains unique values of 1,5 and 6:
18 5 1 314 2 1 2- The values in column 4 are contiguous 4 2 5 92 1 5 7- The values in column 4 are NOT contiguous. (Missing '8' in Col 4)1 5 6 73 3 6 13 7 6 516 6 6 35 3 6 6- The values in column 4 are NOT contiguous. (Missing '2','4' in Col 4)
Result: [0 1 2]
How can I perform this complex computation? Ideally, the results should be stored using just 1 variable (if possible). My code at the moment is way too complicated and not efficient. Any help would be greatly appreciated.
Best Answer