convert to monthly mean (arrange data)
조회 수: 7 (최근 30일)
이전 댓글 표시
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
Geoff Hayes
2014년 9월 24일
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.
채택된 답변
Andrei Bobrov
2014년 9월 25일
편집: Andrei Bobrov
2014년 9월 25일
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})]];
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!