how to plot monthly means data to show seasonal change over 47 years?

10 visualizaciones (últimos 30 días)
i have monthly means of 47 years. i.e. for each year i have 12 separate means. i need to show how seasonal mean is changing over 47 years. then i need to show another change of one season say (May-June) for each year, to see the yearly seasonal variaton in this specific season?
here is my data file attached. Data is a timetable having univariate timeseries data. i am planning to reshape the data by keeping year on the rows, months on columns( as currently all the data with years and months are in one column), then i may plot a bar graph for the seasonal change.
but i am not finding a way to do it. the code for normal plot is as below.
let me add, data range is from Jan 1970 to May 2017.
please , guide me
looking forward...BR
plot(monthlymeans_ObsData.timmendorf_time,monthlymeans_ObsData{:,1}', 'b' );
hold on;
% plot(monthlymeans_ObsData.timmendorf_time,monthlymeans_SimData{:,1}', 'g' ); hold on
title('Monthly Trend of Observed and Simulated Data Series');
xlabel('Years: 1971-2017');
ylabel('Monthly Mean');
%% plot bars from monthly data on x-axis
% this will produce 12 x 46 matrix, considering 552 rows uptill year 2016
tt = reshape(monthlymeans_ObsData{1:552,1},12,[]);
bar(tt(:,1:3),'DisplayName','tt(:,1:3)') % first 3 years display of monthly means
hold on
% for month = 5 and 6

Respuesta aceptada

Stephan el 16 de En. de 2019
this is very similar to your other question. Here you can use the rows2vars function, once you have reshaped your table. The code to reshape it the way you want is:
monthlymeans_ObsData.Properties.RowTimes.Format = 'MMM';
% reshape the data as needed
waterlevel = nan(564,1);
waterlevel(1:557) = monthlymeans_ObsData.timmendorf_waterlevel;
waterlevel = reshape(waterlevel,12,47);
% New table
T = splitvars(table(waterlevel));
% Variable Names for new table - columns
years = cell(1,47);
for y = 1:47
years{y} = sprintf('Year_%d',1970+y);
T.Properties.VariableNames = years;
% Variable Names for new table - rows
months = cell(1,12);
month_names = string(monthlymeans_ObsData.Properties.RowTimes(1:12));
for m = 1:12
months{m} = sprintf('%s',month_names(m));
T.Properties.RowNames = months;
% "Transpose" the table you got, so that it meets your requirements
T = rows2vars(T);
% clean up
clear waterlevel y years months month_names m ans
To see how to access the data use my answer to your other question.
Best regards

Más respuestas (0)


Community Treasure Hunt

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

Start Hunting!

Translated by