how to arrange multiple xlsx files in year to seasonal
1 view (last 30 days)
Show older comments
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 Comments
Geoff Hayes
on 28 Dec 2014
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?
Accepted Answer
Andrei Bobrov
on 29 Dec 2014
Edited: Andrei Bobrov
on 29 Dec 2014
[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 Comments
Andrei Bobrov
on 29 Dec 2014
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
More Answers (0)
See Also
Categories
Find more on Labyrinth problems in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!