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

2 visualizzazioni (ultimi 30 giorni)
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 Commenti

Accedi per commentare.

Risposta accettata

Prabhanjan Mentla
Prabhanjan Mentla il 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.

Più risposte (0)

Categorie

Scopri di più su Dates and Time in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by