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
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 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