Converting wind/wave data to hourly data by interpolation
4 次查看(过去 30 天)
显示 更早的评论
Dear All,
I have wind and wave data that as can be seen attached. I want to convert it to hourly data acording to duration (time) values in column A. The value of duration here represents the duration of the wind blowing and its unit is hour. I want to interpolate all the other parameters while converting to hourly data. For example, I have formulated this in Excel for the line as follows,
D2-(($D$2-$D$3)/$A$2)
D3-(($D$2-$D$3)/$A$2)
D4-(($D$2-$D$3)/$A$2)
......
D8-(($D$2-$D$3)/$A$2)
The problem is, this is a very large set of data and doing this manually in Excel will take an enourmous amount of time. Is there a command in MATLAB where I can add (A-1) number of columns to each line and interpolate the rest of columns as described above?
Thank you in advance!
5 个评论
Adam Danz
2022-6-30
Look at the last row of data; it may not be included in the final interpolated timetable. I don't know how you would interpolate that last row but it's just something to keep in mind.
采纳的回答
Adam Danz
2022-6-30
编辑:Adam Danz
2022-6-30
If the durations are consecutive, then I suggest creating an time stamps based on the durations which allows you to use retime to interpolate the timetable to hourly samples.
I've created a "clean" version of your file by removing the rows that were highlighted.
T = readtable('sample_data_clean.xlsx')
% Create time stamps with arbitrary starting date/time
% Note that the time stamps start at hour 0.
arbitraryDateTime = datetime(2000,1,1,0,0,0) + [0;cumsum(hours(T.Duration(1:end-1)))];;
TT = table2timetable(T,'RowTimes',arbitraryDateTime)
% Interpolate to hourly samples
TThourly = retime(TT,'hourly','linear')
Convince yourself that the results are reasonable by plotting the original and interp'd data
figure
plot(TT.Time, TT.WindDirection_degree_,'-b','linewidth',2,'displayname','original');
hold on
plot(TThourly.Time, TThourly.WindDirection_degree_,'-r','displayname','interp''d');
legend
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calendar 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!