Conversion serial date back to calender dates in string format.
Ältere Kommentare anzeigen
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 Kommentar
Stephen23
am 15 Mai 2015
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.
Akzeptierte Antwort
Weitere Antworten (1)
Peter Perkins
am 18 Mai 2015
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.
Kategorien
Mehr zu Dates and Time finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!