필터 지우기
필터 지우기

Extract a range of data acording to the date range from a table

조회 수: 1 (최근 30일)
Mark Rodger
Mark Rodger 2018년 2월 1일
댓글: Guillaume 2018년 2월 7일
I want to separate months of the year from a table into another table for each season.
  댓글 수: 3
Mark Rodger
Mark Rodger 2018년 2월 1일
It's part of my project where I need to show the wind speed for each season. The table has 2 years of wind speed with two variables: Time and WindSpeed. Could you help me with this?
Mark Rodger
Mark Rodger 2018년 2월 7일
I forgot to mention that the table has 2 years worth of data (2013-2014). Is there a way to extract one season of one year

댓글을 달려면 로그인하십시오.

채택된 답변

Peter Perkins
Peter Perkins 2018년 2월 1일
There's only four seasons, best to not overthink this.
spring = t(ismember(month(t.Time),1:3),:);
etc. But Guillaume's advice is worth thinking about.
  댓글 수: 3
Fraser McMurray
Fraser McMurray 2018년 2월 7일
편집: Fraser McMurray 2018년 2월 7일
If you want to view a specific year you can try this:
april = x(ismember(month(x.time),4),:);
april2013 = april(ismember(year(april.time),2013),:);
Guillaume
Guillaume 2018년 2월 7일
Again, it is very likely that you don't need to separate the table at all and that it may be more efficient to work on the whole table at once.
For example, if you wanted to calculate the mean wind speed per season per year:
[group, season, year] = findgroups(discretize(month(yourtable.time), [1 4 10 12]), year(yourtable.time));
meanwindspeed = splitapply(@mean, yourtable.windspeed, group);
result = table(season, year, meanwindspeed)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by