Converting wind/wave data to hourly data by interpolation
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Seda Cora Özdemir
le 30 Juin 2022
Commenté : Adam Danz
le 30 Juin 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 commentaires
Adam Danz
le 30 Juin 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.
Réponse acceptée
Adam Danz
le 30 Juin 2022
Modifié(e) : Adam Danz
le 30 Juin 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Tables dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
