MATLAB: Importing and Analyzing .txt files

data importimporting excel dataMATLAB

How can I import multiple files into matlab and then for example only get data from certain columns and certain parts of that column? For example I could have a .txt file with 1,000 lines and 3 columns (date, flowrate1,flowrate2). The dates range from jan-dec and I only want to import data from columns 2,3 (flowrate1,flowrate2) from the month of March?

Best Answer

You can use readtable() and convert to timetable() objects, and use timerange() indexing.
Alternately, you can use readtable(), and use month() on the date column, and compare the result to 3 in order to get a mask for which rows to use. Note that this would find all March items from separate years if there are multiple years in the file.