Linear Interpolation hard task
1 view (last 30 days)
Show older comments
Ok so i will try to simplify my problem here and explain it. I have some sensor readings of power with corresponding time stamps. An example extract is shown below.
Timestamp Power
2021-04-01 15:07:19 0.0834
2021-04-01 15:08:02 0.0726
2021-04-01 15:08:42 0.0123
2021-04-01 15:09:24 0.0999
As you can see that the sensor data unfortunately has no fixed time interval between data readings.
My goal is to create a new table with a fixed time interval of one minute. In this table the Timestamp will go from 2021-04-01 00:00:00 till
2021-04-01 23:59:00 ( A total of 1440 readings for 24 hours). I have done this part already.
Now comes my question. How to i linearly interpolate the data above to match up with with my new time stamps? The challenge is also to automatically fill in the power readings with '0' on timestamps where no data was recorded.
What i mean to say is, the raw sensor data file dosent start its readings on 2021-04-01 00:00:00, but on a random time of the day,
like 2021-04-01 07:19:51. Thats why i want to automatically fill in power values with 0 when no data is recorded.
Calling out on all MATLAB heros out there to help me. Thanks alot in advance!
Note: I'll attach the real sensor file so you guys can get the feel of the problem.
2 Comments
Answers (1)
Akira Agata
on 18 Jun 2021
As @Walter Roberson -san suggested, timetable and retime is the best solution. Please try the following:
TT = readtimetable('_sd_OPV_OPV_1_dp_2021_04_01.csv',...
'VariableNamingRule','preserve');
TT2 = retime(TT,'minutely','linear');
0 Comments
See Also
Categories
Find more on Logical 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!