Conversion serial date back to calender dates in string format.
이전 댓글 표시
Hello all, I have been trying to analyize wind measurement data. The dataset contains, measurement time, direction and wind speeds at different heights.The measurement has gab and I would like to replace this gaps by NaN. To do that I began producing constant timestep and replace in the time measurment so that to replace the observation by NaN. However I could not do that therefore would you please help me? here is the matlab code:
ds1b=dataset('file','1201b.txt')
time_initial=ds1b.Time(:);
time_initialmat=datenum(time_initial)*86400;
time_final=ds1b.Time(end);
time_finalmat=datenum(time_final)*86400;
time_range=time_finalmat-time_initialmat;
calltime(1,1)=time_initial
for i =1:tim_range
time_initialmat= time_initialmat+1;
calltime(i,1)=datestr(time_initialmat/86400, ...
'ConvertFrom','datenum','Format','yyyy-MM-dd HH:mm:ss'));
end
auxtime=dataset(calltime,'VarNames','Time');
res=join(dsb1, auxtime, 'Type', 'rightouter', 'MergeKeys', true);
댓글 수: 1
Stephen23
2015년 5월 15일
If you actually attach your data file then we can try your code too!. Please edit your question, click the paperclip button, and then both Choose file and Attach file.
채택된 답변
추가 답변 (1개)
Peter Perkins
2015년 5월 18일
In R2014b or later, using table and datetime, this becomes:
data = readtable('1201b.txt','Format','%{yyyy-MM-dd HH:mm:ss}D%f%f%f%f%f%f%f%f%f%f','Delimiter','\t');
allTime = min(data.Time):seconds(1):max(data.Time);
allData = NaN(length(allTime),width(data)-1);
allData = [table(allTime') array2table(allData)];
allData.Properties.VariableNames = data.Properties.VariableNames;
haveData = ismember(allTime,data.Time);
allData(haveData,2:end) = data(:,2:end);
Hope this helps.
카테고리
도움말 센터 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!