Hello,
I'm facing the following problem:
I have a matrix A(X,1) which contains time data. The time is given in steps of 20 seconds, so 0, 30, 75 etc. means for example 05:00:00, 05:10:00, 05:25:00 [hrs:min:sec] respectively.
Now the problem is some actions X have the same time value. This shouldn't be the case as each action should take place at a unique time.
What I want to do is to add a timestep of 20 or 40 seconds to a time (i) which is the same as the value before (i-1). Though the new value (i) shouldn't overshoot or equal the time of the next value (i+1).
An example is the following:
A(1:6,1)= 225 [06:15:00]A(7:19,1)= 240 [06:20:00]A(20:22)= 255 [06:25:00]
Now for the first case A(1:5,1) there are only 6 values which are the same. As a result, the timevalues of A(2:6,1) should be adapted such that they are not equal to A(1,1) and are still smaller than A(7,1). To do so, 2 time steps can be added to each value. I.e. A(2,1)= 227, A(3,1)= 229 etc.
However, for A(7:19,1) only 1 time step can be added as 2 time steps will lead to an overshoot w.r.t. A(20,1).
So if there are <8 of the same time values, 2 time steps can be added; if >=8 then only 1 time step can be added.
Can anyone help me writing a code for this procedure?
Best Answer