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

1 次查看(过去 30 天)
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 个评论

请先登录,再进行评论。

采纳的回答

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 CenterFile Exchange 中查找有关 Dates and Time 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by