How to create a new column vector with set increments to increase consistently cell by cell?

6 views (last 30 days)
I have a file 360012-by-19, the first column of which is a time series which currently increses in inconsistent steps starting at 0.26. I need this time series to have consistent steps, so I need to insert a new column which starts at 0.26 and increases by 0.01 for each cell down the column until it hits 360012 cells.
Currently I have tried x = linspace(0.26,3600.37,360012) (where 3600.37 is derived from (0.01*360011)+0.26. When I check the difference in the first 5 cells of the column to see if it has worked, it appears so, showing 0.010000000000000 consistently. However when I check the difference in the last 5 values (using: diff(data(360007:end,1)) ) I have:
0.010000000000673
0.009999999999309
0.009999999999764
0.010000000000673
0.009999999999764
And if I use the second method I know: x = 0.26:0.01:3600.37; I get a similar problem:
0.010000000000218
0.009999999999764
0.010000000000218
0.009999999999764
0.010000000000218
I have checked through samples of the column, and it appears that from cell 200 onwards, the time step starts to become inconsistent, showing occassional 0.010000000000001 and 0.010000000000002 and so on, and continues to deteriorate until it becomes the above at the endof the column.
I can't understand why, when I am setting the desired increments and creating a completely new vector, it is giving me an inconsistent, deteriorating difference... Any help would be greatly appreciated, I'm on a very short timescale and am going out of my mind over this!
Thankyou!

Answers (0)

Categories

Find more on Programming 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!