# MATLAB: Remove values below/above limits in first row of 2byx array and related values in second row.

timestamps

I have two row-vectors. One relates to time values (datenums), the other related data at those timestamps. I wish to remove all values before and after a time AND remove related data values.
Working on just the time data is easy as it is in chronological order so I can obtain the values I require.
I have tried creating an array with the vectors and removing the values in the same way. This does not remove the related data values (long shot).
How can I do this? Assume time in row 1 and data row 2.
thanks
Mark

• time=1:10values=rand(1,10)idx=time>5 & time <8new_time=time(idx)new_values=values(idx)