# Calculation of diurnal cycle

조회 수: 9 (최근 30일)
Daphne PARLIARI 2020년 1월 28일
댓글: Star Strider 2020년 1월 30일
Hi everyone!
I have some .csv files (attached you can see one of them) containing hourly values of temperature and humidity from 1/7/2019 to 30/9/2019. Frome these values I want to extract the diurnal cycle of temperature and humidity, which means 1 mean value for all dates at 00:00, one for 01:00, till 23:00.
What is the most efficient way to do so?
##### 댓글 수: 2없음 표시없음 숨기기
darova 2020년 1월 28일
What about mean function? Did you try it?
Daphne PARLIARI 2020년 1월 29일
Sure but I want to take the mean considering the hours, that's what I am not sure how to achieve...

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

### 채택된 답변

Star Strider 2020년 1월 29일
Try this:
Hrs = hour(D.Date); % Hours
[UHr,~,ic] = unique(Hrs); % Hours Reference Index Vector
TRH = accumarray(ic, (1:numel(Hrs)).', [], @(x){mean([D.Temp(x),D.RelHum(x)])}); % Means By Hour
TRHmtx = cell2mat(TRH); % Matrix From Cell Array: [Temp RelHum]
figure
yyaxis left
plot(UHr, TRHmtx(:,1))
ylabel('Temperature (°C)')
yyaxis right
plot(UHr, TRHmtx(:,2))
ylabel('Relative Humidity (%)')
grid
xlabel('Time (Hours)')
set(gca, 'Xtick',(0:23))
xlim([0 23])
producing:
##### 댓글 수: 2없음 표시없음 숨기기
Daphne PARLIARI 2020년 1월 30일
Thank you!!!
Star Strider 2020년 1월 30일
As always, my pleasure!

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

### 카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by