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 Comments

What do all the mat files mean by their names, not so clear
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 on 16 Aug 2021
Edited: Pul on 16 Aug 2021
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.

Sign in to comment.

 Accepted Answer

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

More Answers (0)

Asked:

Pul
on 15 Aug 2021

Commented:

Pul
on 16 Aug 2021

Community Treasure Hunt

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

Start Hunting!