convert to monthly mean (arrange data)

7 Ansichten (letzte 30 Tage)
skyhunt
skyhunt am 22 Sep. 2014
Kommentiert: skyhunt am 27 Sep. 2014
I attached here 2 text files ..one is input file(complete data of year,month number,Day1 to day31) and second one is output file(year, month wise mean).I want this output format only.
  6 Kommentare
skyhunt
skyhunt am 24 Sep. 2014
Bearbeitet: skyhunt am 24 Sep. 2014
I am very new to this matlab. Still i am not getting my format..please anybody help for this script..save my life
Geoff Hayes
Geoff Hayes am 24 Sep. 2014
What happened when you loaded the data from file using importdata? Please post some or all of the code that you have written to accomplish this task.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 25 Sep. 2014
Bearbeitet: Andrei Bobrov am 25 Sep. 2014
f=fopen('input.txt');
c = textscan(f,repmat('%f ',1,33),...
'EmptyValue',nan,'HeaderLines',1,'CollectOutput',1);
fclose(f);
c1 = c{1};
val = nanmean(c1(:,3:end),2);
[yrs,~,ii] = unique(c1(:,1));
mmm = cellstr(datestr(datenum(2014,(1:12)',1),'mmm'))';
output = [[{'year'},mmm];
[num2cell(yrs), accumarray([ii, c1(:,2)],val,[],@(x){x})]];
  4 Kommentare
skyhunt
skyhunt am 26 Sep. 2014
I changed tilde with N, now it is working...how to write loop for this about 100 xlsx sheets?..
skyhunt
skyhunt am 27 Sep. 2014
I created batch file as 'files.dat', with in that 100 .dat files are there ,and I want create for loop for this above script,please help me..?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by