Ranges with different step size for odd and even steps in MATLAB
matlab
Solution
You can obtain the cumulative sum of the vector of steps (in your case it is `[1 2 1 2 1 2 1 2 ...]`). For example:
x = cumsum([0, repmat([1 2], 1, 4)])
x =
0 1 3 4 6 7 9 10 12
Problem
What is the fastest and the simplest way to generate an array like `[0, 1, 3, 4, 6, 7, 9, 10, ...]` in MATLAB?