Converting wind/wave data to hourly data by interpolation
3 views (last 30 days)
Show older comments
Seda Cora Özdemir
on 30 Jun 2022
Commented: Adam Danz
on 30 Jun 2022
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 Comments
Adam Danz
on 30 Jun 2022
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.
Accepted Answer
Adam Danz
on 30 Jun 2022
Edited: Adam Danz
on 30 Jun 2022
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 Comments
More Answers (0)
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!