Remove values below/above limits in first row of 2byx array and related values in second row.
1 view (last 30 days)
Show older comments
Mark Gambrill
on 22 Jun 2015
Commented: Mark Gambrill
on 22 Jun 2015
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
0 Comments
Accepted Answer
Azzi Abdelmalek
on 22 Jun 2015
Edited: Azzi Abdelmalek
on 22 Jun 2015
time=1:10
values=rand(1,10)
idx=time>5 & time <8
new_time=time(idx)
new_values=values(idx)
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, :) = []
See Also
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!