필터 지우기
필터 지우기

Help ! Average half hourly into 3 hours and save the file as mat with filename reflecting the startTime and Endtime

조회 수: 1 (최근 30일)
Hi,
I'm reading half hourly HDF5 files, on which I run some analysis. I want to now average these processed half hourly into 3 hours. This does NOT run.
clc
clear all
sad = dir( fullfile('path', '*.HDF5' )); %% all the HDF5 files in the folders for two years and half hourly
for ii = 1:length(sad)
[data, name] = read_one_file(sad(ii).name) ; %%% read_one_file where my hour half files are processed
while (data(ii).TimeID - data(ii).TimeID) == 0 %% TimeID is same for half hourly files within 3 hour windows, so have 8 uniques values for a day
new = nanmean(data(ii).H); %%% here i want to average all the var fields in data strcuture where my TimeID remains same and for same date
extention='.mat'; %%% ext
matname = fullfile('path\test', [[name,num2str(StartTime(ii)),num2str(EndTime(ii))] extention]) % want to save with file with startTime and EndTime
save(matname,'new');
end
end
My data structure has following fields;
data.H ; data.Th ; data.Date ; data.EndTime ; data.StartTime ; data.TimeID ;
  댓글 수: 3
nlm
nlm 2018년 11월 15일
No I haven't. I understand while loop is wrong, I don't know how to move forward...
for ii = 1:length(sad)
if data(ii).TimeID == unique(data(ii).TimeID)
IMERG = nanmean(data(ii).H,3);
end
end
This saves average only for one TimeID. The problem is either I have to run for entire ii which is 17000 HDF5 half an hour files with 2 of 400 * 900 matrices in each file and then average (which I did for 100 files and it works ), or I run for few files and do an 3 hr average and save only that file?
Walter Roberson
Walter Roberson 2018년 11월 16일
each iteration of the for loop you are overwriting all of data. You should be storing into data(i) instead . Have it read all of the data first, and then it can make sense to process the data from several files together .

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 HDF5에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by