How can I transform these data into seasonal data?

Hello everyone,
I should transform monthly data into seasonal data and yearly data into seasonal data: [1) December-January; 2) From March to October; 3) November; 4)February] and then doing the average.
Can anyone help me kindly?
Thank you.

댓글 수: 6

What do all the mat files mean by their names, not so clear
Scott MacKenzie
Scott MacKenzie 2021년 8월 15일
편집: Scott MacKenzie 2021년 8월 15일
I believe you have asked this question before, and it has been answered (click here). Please explain how this new question differs from the previous question.
Yes, but those data are different, because they are organized in a different way.
I tried in the same way of the question you mentioned and it didn't work.
Here an example:
load('DATI_MAR_mensili');
DATI_MAR_SEASON=retime(DATI_MAR_SEASON,'monthly','mean');
s30Logical = month(DATI_MAR_SEASON.Year) == 12 | month(DATI_MAR_SEASON.Year) == 1; % Dec, Jan
s31Logical = month(DATI_MAR_SEASON.Year) >= 3 & month(DATI_MAR_SEASON.Year) <= 10; % Mar to Oct
s32Logical = month(DATI_MAR_SEASON.Year) == 11; % Nov.
s333Logical = month(DATI_MAR_SEASON.Year) == 2; % Feb.
% seasonal data, as per question
s30 = DATI_MAR_SEASON(s30Logical,:); % dec, jan
s31 = DATI_MAR_SEASON(s31Logical,:); % mar to oct
s32 = DATI_MAR_SEASON(s32Logical,:); % nov
s33 =DATI_MAR_SEASON(s33Logical,:); % feb
plot(s30.Year,s30.SMB_larsenmm,s30.SMB_priestleymm,s30.SMB_talosmm,SMB_mpmm,'r');
hold on
plot(s31.Year,s31.SMB_larsenmm,s31.SMB_priestleymm,s31.SMB_talosmm,SMB_mpmm,'b');
hold on
plot(s32.Year,s32.SMB_larsenmm,s32.SMB_priestleymm,s32.SMB_talosmm,SMB_mpmm,'g');
hold on
plot(s33.Year,s33.SMB_larsenmm,s33.SMB_priestleymm,s33.SMB_talosmm,SMB_mpmm,'m');
hold on
Thank you.
OK, I get it. You are now working with new data which are organized differently. Well, step #1 is always to know and understand the organization of the data you are working with. Some fiddling might be necessary to get the data organized in a way that suits your purpose.
The load command in your comment loads data into a table (not a timetable). Upon inspection, I notice there is no datetime column, so you'll have to make one. In this case, columns 1 and 2 are 'Year' and 'Month'. So, you need to make and add a datetime column from these columns. Then you can convert to a timetable, and continue with the code in the answer to your earlier question; i.e., define your seasons, use grpstats to get seasonal summaries, plot, etc.
Here's some code to get you started with the data in your comment.
load('DATI_MAR_mensili');
% NOTE: loads a table with 'Year' and 'Month' columns
% add date/time column labeled 'Time'
DATIMARmensili.Time = datetime(DATIMARmensili.Year, DATIMARmensili.Month, 0);
% convert to timetable with all the other data columns
DATI_MAR_SEASON = table2timetable(DATIMARmensili(:,3:end));
% define seasons, as in previous question/answer, and continue
Pul
Pul 2021년 8월 16일
편집: Pul 2021년 8월 16일
Thank you!
I want to accept your answer, but it doesn't give me the option and I don't know why.
OK, I'll also put the code from my comment into answer box.

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

 채택된 답변

Scott MacKenzie
Scott MacKenzie 2021년 8월 16일
Note: Code in comment moved here...
load('DATI_MAR_mensili');
% NOTE: loads a table with 'Year' and 'Month' columns
% add date/time column labeled 'Time'
DATIMARmensili.Time = datetime(DATIMARmensili.Year, DATIMARmensili.Month, 0);
% convert to timetable with all the other data columns
DATI_MAR_SEASON = table2timetable(DATIMARmensili(:,3:end));
% define seasons, as in previous question/answer, and continue

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

Pul
2021년 8월 15일

댓글:

Pul
2021년 8월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by