Skip to content

Instantly share code, notes, and snippets.

@shaybensasson
Created March 4, 2015 09:05
Show Gist options
  • Save shaybensasson/58a225cc6eb382b898ea to your computer and use it in GitHub Desktop.
Save shaybensasson/58a225cc6eb382b898ea to your computer and use it in GitHub Desktop.
filter range of values
%% filter range of values
rawData = 1900:5:2100;
from = 1982;
to_excluded = 2015;
indexes = 1:length(rawData);
%declare indexes for the whole data range
filter = logical(rawData(:) >= from & rawData(:) < to_excluded);
%contains 1 where we care
indexesOfFilteredData = indexes(filter);
%get all the indexes that have 1s
filteredData = rawData(indexesOfFilteredData);
%filter the data by these indexes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment