how to arrange multiple xlsx files in year to seasonal

1 次查看(过去 30 天)
Hi.. I have 47 xlsx files and i want arrange year to seasonal. i attached my input and output xlsx files here. From this i want to plot 47 xlsx file's Nov mean (month) vs Year (1971-72 to 2000-01); like wise all months (Dec,Jan,Feb,Mar,Apr) please help me..i waiting for your helpful replying Thank you....
  2 个评论
Geoff Hayes
Geoff Hayes 2014-12-28
Please clarify how the 47 Excel files fit into your question. What does each file represent? i.e. is this the data from a particular city for 12 months of the year from 1971-2001, or is it something else?
skyhunt
skyhunt 2014-12-29
编辑:skyhunt 2014-12-29
I have 47 stations precipitation data and the data format in Excel files. Each Data file represents 12 months (Jan-Dec) from 1971 to 2001.I want to calculate seasonal mean from Nov-Apr(Nov,Dec,Jan,Feb,Mar,Apr); I want to arrange like this 1971-72 (Nov,Dec,Jan,Feb,Mar,Apr) 1972-73 (Nov,Dec,Jan,Feb,Mar,Apr) etc...

请先登录,再进行评论。

采纳的回答

Andrei Bobrov
Andrei Bobrov 2014-12-29
编辑:Andrei Bobrov 2014-12-29
[n,tt] = xlsread('input.xlsx');
m = size(n,1);
[ii,~] = ndgrid(1:12,zeros(m,1));
j1 = find(ii == 11,1,'first');
j2 = find(ii == 4,1,'last');
n1 = n(:,2:end)';
n2 = n1(j1:j2);
out1 = reshape(n2((rem(0:numel(n2)-1,12)+1) <= 6),6,[])';
out = [n(1:m-1,1), n(2:m,1), out1];
OR just
[n,tt] = xlsread('input.xlsx');
out = [n(1:end-1,1), n(2:end,1), n(1:end-1,11:12), n(2:end,2:5)];
  3 个评论
Andrei Bobrov
Andrei Bobrov 2014-12-29
Let name your xlsx files is as 'nameyourfileinput1.xlsx', 'nameyourfileinput2.xlsx' and etc.
t1 = dir('nameyourfileinput*.xlsx');
nn = {t1.name};
mth = cellstr(datestr(datenum(2014,1:12,1),'mmm'));
nexl = [{'year1','year2'},mth([11,12,1:4])'];
for jj = 1:numel(t1)
n = xlsread(nn{jj});
nout = [n(1:end-1,1), n(2:end,1), n(1:end-1,11:12), n(2:end,2:5)];
xlswrite(sprintf('nameyourfileoutput%02d.xlsx',jj),...
[nexl;num2cell(nout)],1,sprintf('A1:H%d',size(nout,1)));
end

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by