How to treat a duration array in a for loop?
Afficher commentaires plus anciens
My overall goal: I have measurements from different sensors which are performed simoultaneously, but with different timesteps. Now, I want to use both outputs in order to do some calculations.
So, I need to calculate mean values from some measurements (e.g. timesteps of each 10sec) in order to put them into the same format likewise the other measurements (timesteps of each 10min). In the end I want to have the different measurements with equal timesteps.
Hence, one table and its timesteps represent a pattern, and I want to convert the other table into the same pattern with regard to the timesteps.
Therefore, I have started to build up a for loop to write a table with (1) the timesteps and (2) the corresponding calculated mean values. I have started with the timesteps, but I am facing an issue with the duration array within this for loop. It gives me "Error using duration/double".
My short code so far:
%% read input file (csv) and determine output path
in_timesteps = 'C:\Users\Judith\Desktop\phd\Data\Hukseflux\Calculations\26.07.2021_28.07.2021_calc_Enet.csv';
in_measured = 'C:\Users\Judith\Desktop\phd\Data\daten_wetterstation\WL__2021_07_27.csv';
measure_day = '27.07.2021';
output = 'C:\Users\Judith\Desktop\phd\Data\Hukseflux\Calculations\';
data_timesteps = readtable(in_timesteps, 'NumHeaderLines', 0, 'Delimiter', ',' ,'DecimalSeparator', '.', "VariableNamingRule" , "preserve");
data_measured = readtable(in_measured, 'NumHeaderLines', 0, 'Delimiter', ',' ,'DecimalSeparator', '.', "VariableNamingRule" , "preserve");
data_measured.Properties.VariableNames = regexprep(data_measured.Properties.VariableNames, ' ', '_');
%date = unique(data_timesteps.Date);
%%
ind_dt = find(data_timesteps.Date == measure_day);
H = zeros(sum(data_timesteps.Date == measure_day),2);
for i = 1:(sum(data_timesteps.Date == measure_day))
H(i,1) = data_timesteps.Time(ind_dt(i))
end
%%
% ind_time = find(data_measured.Time > data_timesteps.Time(1) & data_measured.Time < data_timesteps.Time(2) & data_measured.Date == measure_day);
% x = mean(data_measured.WD__Avr(ind_time));
% new_table = table(data_timesteps.Time(2), x);
Any help is very much appreciated.
1 commentaire
JMSE
le 3 Août 2021
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!