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!