Convert/interpolation target factors into hourly bases frequency for interpolated in between data

3 views (last 30 days)
Hello Everyone
I have a data set that presents 3 different factors (Temp, Co2 and humidity) that were collected using different sensors for 35 days. These Input factors data were collected at 5 minutes frequency while target factors data were collected at 5 days frequency. The input factors were averaged to be represented as hourly points (instead of 5 minutes). My question is, Is there any proper way to convert the target factors into an hourly basis frequency for interpolating in between data, so, this dataset will be trained using NNs for example for prediction purposes.
Thanks in advance for helping.
Regards

Answers (1)

Hari
Hari on 10 Jan 2024
Hi Gadelhag M Omar Mohmed,
I understand that you have a dataset with input factors collected at 5-minute intervals and target factors collected at 5-day intervals. You have averaged the input factors to hourly data and now seek a method to interpolate the target factors to an hourly frequency to align with the input data for neural network training.
Assuming you have the target factors in a MATLAB array or table and the timestamps for both the input and target data, you can use MATLAB interpolation functions to resample the target factors to an hourly frequency.
Here's a general approach using "interp1" function:
% Assuming targetTimes is a datetime array of the timestamps when target data was collected
% targetData is an array of the target factors data
% hourlyTimes is a datetime array of the timestamps for each hour in the 35-day period
% Convert the 5-day frequency data to hourly data using linear interpolation
hourlyTargetData = interp1(targetTimes, targetData, hourlyTimes, 'linear', 'extrap');
% 'extrap' allows extrapolation for points outside the range of targetTimes
This code snippet assumes that "targetTimes" and "hourlyTimes" are datetime arrays with the timestamps of the target data collection and the desired hourly timestamps, respectively. The "targetData" array holds the actual target factor values. The "linear" option specifies linear interpolation, and "extrap" allows the function to extrapolate values outside the original data range, which you might need since the target data is sparse.
Refer to the documentation of interpolation function "interp1" for more information on how to perform interpolation of data:
Hope this helps!

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!