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

1 view (last 30 days)
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 Comments

Sign in to comment.

Accepted Answer

Prabhanjan Mentla
Prabhanjan Mentla on 27 Mar 2020
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.

More Answers (0)

Categories

Find more on Dates and Time in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!