Remove values below/above limits in first row of 2byx array and related values in second row.
Show older comments
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
Accepted Answer
More Answers (1)
Guillaume
on 22 Jun 2015
Use logical indexing on the rows, and : (colon) to remove the whole rows:
data = [(datenum(2015,6,22):datenum(2015,7,22))' (1:31)'] %example data
%find rows before 30th June or after 15th July
toremove = data(:, 1) < datenum(2015,6,30) | data(:, 1) > datenum(2015,7, 15);
data(toremove, :) = []
1 Comment
Mark Gambrill
on 22 Jun 2015
Categories
Find more on Dates and Time 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!