Extracting rows associated with a month written in string form in a table

1 回表示 (過去 30 日間)
Tully_N
Tully_N 2020 年 3 月 23 日
コメント済み: Tully_N 2020 年 3 月 27 日
Hi there!
I have imported a data set using readtable that has a column of months to the left of various columns of data associated each month. The column with the months in it is called 'Month' and each month in the column is written as a string ('Jan', 'Feb', 'Mar' etc.).
I am trying to find all of the rows associated with May so that I can extract and average all of the data associated with this month, (i.e. I would love an array with the rows associated with May, i.e. [4, 21, 89, 164]) however I am struggling to find a way to code this, as all of the techniques I have found don't seem to work for a table of data. I am also struggling to convert the months into a numerical form which might be easier?
Thanks for your help!
  3 件のコメント
Tully_N
Tully_N 2020 年 3 月 27 日
Thank you for your help, much appreciated!

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

採用された回答

Prabhanjan Mentla
Prabhanjan Mentla 2020 年 3 月 27 日
I assume you want to extract all the rows of the given label.
You may try something like this
d = readtable(filename)
d(strcmp(d.Month, 'May'), :)
The below link helpful for accessing data in a table.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by