Importing and Analyzing .txt files

3 ビュー (過去 30 日間)
Marcos Perez Rodriguez
Marcos Perez Rodriguez 2019 年 10 月 5 日
編集済み: dpb 2019 年 10 月 6 日
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?
  1 件のコメント
dpb
dpb 2019 年 10 月 5 日
編集済み: dpb 2019 年 10 月 6 日
Just read the full file and then select the subset of data wanted...if you only import the flow data, you don't have the date data from which to select.
One good way would be to use detectimportoptions first, then use that object with readtable and it most likely will be able to automagically import the date column as datetime which is easy to use to select dates within ranges.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2019 年 10 月 5 日
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.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by