C = mod((1:sum(A)) - 1, 3) + 1; cumsum with reset '3' value and delete repeated values
newA = 0 * A;
newA( logical(A) ) = C;
and now do your interpolation. However, you cannot use interp1() because interp1() would use the 3's as the basis of interpolation rather than resetting to 0.
Best Answer