hourly average for the monthly data
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
i want to hourly average the data given follow, for each day in month (4th column is the value which i want to hourly average) i try looping the following program still not getting result, please you can help me with this.
clc
clear
t=xlsread('jan',1,'A1:A'); % t=xlsread('worksheet name' ,1,'Range of elements')
date1 = datevec(t) % Convert char into vector form
elecf = xlsread('jan',1,'B1:B');
[a,~,c] = unique(date1(:,1:4),'rows');
for i=1:30
out(i,1)= [a,zeros(size(a,1),2),accumarray(c,elecf(:,1),[],@nanmean)];
out(i,2)= [a,zeros(size(a,1),2),accumarray(c,elecf(:,1),[],@nanmean)];
end
댓글 수: 0
답변 (1개)
Guillaume
2019년 2월 4일
Unless you're using a very outdated version of matlab, there's a much easier way to do everything you've done
t = readtable('jan', 'A:B'); %read excel (? it would be better to specify the file extension) file all at once
%Normally, if column A is a date in excel, t.Var1 would be datetime
%If not, convert it to datetime, not datenum
%t.Var1 = datetime(t.Var1, 'InputFormat', ... %format to specify)
t = table2timetable(t); %convert to timetable
retime(t, 'hourly', 'mean') %get hourly average
댓글 수: 0
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!