converting irregular space data into regular spaced data for time line interpolation

HI i was given a dataset that has irregular spaced time and temperature.I am now struggling to do a time series linear interpolation since i dont know how to create a regularly spaced on hour time series from the data given. for example vq = interp1(x,v,xq,method,extrapolation);
i have the values for x and v but not xq. so how do i get the regular spaced data?
%%load data
A = load('../data2/Q1_data.txt');
B = load('../data2/Q2_data.txt');
C = load('../data2/Q3_data.txt');
D = load('../data2/Q4_data.txt');
%%Question 1 interpolation
a_date = (A(:,1));
a_temp = (A(:,2));
a_hourly = ?
A_linear = interp1(a_date, a_temp, min(a_hourly):max(a_hourly), 'linear', 'extrap');

 Accepted Answer

I'm not entirely clear what your question is. If you want to retime some sampled data, the easiest is to use a timetable.
This could be as simple as:
tt = table2timetable(readtable('../data2/Q1_data.txt'));
tt = retime(tt, 'hourly');
Note: never create sequential variable names (such as your A, B, C, D). These should go in a single matrix or cell array instead.

More Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Asked:

FMR
on 17 May 2018

Answered:

on 17 May 2018

Community Treasure Hunt

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

Start Hunting!