I have an annual data set:
Jday = datenum('2009-01-01 00:00','yyyy-mm-dd HH:MM'):1/24:...
datenum('2009-12-31 23:00','yyyy-mm-dd HH:MM');
DateV = datevec(Jday);
dat = 1+(10-1).*rand(length(Jday),10);
noise = 10*sin(2*pi*Jday/32)+20;
for i = 1:size(dat,2);
dat2(:,i) = dat(:,i)+noise';
end
which represents temperature measurements recorded through a water column. I would like to calculate the temperature range between 06:00 and 18:00 for each day so that I end up with 365 values for each depth so a final matrix of 365x10.
I can specify the individual days by:
[~,~,b] = unique(DateV(:,2:3),'rows');
But I cant work out how to only consider values recorded between 06:00 am and 18:00 pm. Could anyone provide some information about the best possible way of doing this?
Amended: slightly long answer
Jday = datenum('2009-01-01 00:00','yyyy-mm-dd HH:MM'):1/24:...
datenum('2009-12-31 23:00','yyyy-mm-dd HH:MM');
DateV = datevec(Jday);
dat = 1+(10-1).*rand(length(Jday),10);
noise = 10*sin(2*pi*Jday/32)+20;
for i = 1:size(dat,2);
dat2(:,i) = dat(:,i)+noise';
end
for i = 1:size(dat2,2);
data = [DateV(:,4),dat2(:,i)]; % obtain all hours from DateV array
dd = find(data(:,1) == 6); % find 06:00
dd(:,2) = find(data(:,1) == 18); % find 18:00
for ii = 1:size(dd,1);
result(ii,i) = range(data(dd(ii,1):dd(ii,2),2)); % calculate range
end
end