Averaging daily values from annual data

Hi there,
I have a 2 column matrix of Date (dd:mm:yyyy ss:mm:hh) and wave height for 8372 records over a year, one record per hour.
What would be the best way to find a mean wave height for each day and plot this? Some days have more records than others.
I am fairly new to Matlab and understand that I need to convert using datenum first. Please help!
Alternatively, how would I run a moving average over the data for a specified number of records?
Thank you.

댓글 수: 1

per isakson
per isakson 2015년 7월 31일
"8372" &nbsp that is not a full year of hourly data. Which hours are missing?

댓글을 달려면 로그인하십시오.

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2015년 7월 31일

0 개 추천

f = fopen('data.txt');
c = textscan(f,'%s %s %f');
fclose(f);
[y m d] = datevec(datenum(strcat(c{1:2}),'dd:mm:yyyySS:MM:HH'));
[a,~,c1] = unique([y m d],'rows');
out = [a, accumarray(c1,c{3},[],@mean);

카테고리

도움말 센터File Exchange에서 Time Series Objects에 대해 자세히 알아보기

질문:

JH
2015년 7월 31일

답변:

2015년 7월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by