COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Using interp1 for timeseries data

• Follow

```Hi,

I am trying to do some interpolation of timeseries data (24 hours) over different months but my timeseries are not continous.
Here is an example of the timeseries:
A= [2007	11	19	0
2007	11	19	23
2008	3	15	0];

I have the data for November 2007 with hourly data, then I have data for March 2008 with hourly data. How do I interpolate between the hourly monthly data to make it hourly data between November 2007 to March 2008?

Thank you
```
 0

```"Yvonne " <hwt3@waikato.ac.nz> wrote in message <hrcsbs\$987\$1@fred.mathworks.com>...
> Hi,
>
> I am trying to do some interpolation of timeseries data (24 hours) over different months but my timeseries are not continous.
> Here is an example of the timeseries:
> A= [2007	11	19	0
>      2007	11	19	23
>      2008	3	15	0];
>
> I have the data for November 2007 with hourly data, then I have data for March 2008 with hourly data. How do I interpolate between the hourly monthly data to make it hourly data between November 2007 to March 2008?
>
> Thank you

There is probably another (better/easier) way using cells but this is one way:

-Calculate what each day is in relation to the first hour of the first day being zero.
-Then convert each full date/time (year, month, day,hour) to the hours past the first time, put these all in a vector.
-You now have a vector with all the times for which you have data.
-Run interp1 on this vector.

There is probably a file on the FEX to help with getting day of year.
```
 0

```On Apr 30, 9:06=A0am, "Yvonne " <h...@waikato.ac.nz> wrote:
> Hi,
>
> I am trying to do some interpolation of timeseries data (24 hours) over d=
ifferent months but my timeseries are not continous.
> Here is an example of the timeseries:
> A=3D [2007 =A0 =A0 =A0 =A011 =A0 =A0 =A019 =A0 =A0 =A00 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0
> =A0 =A0 =A02007 =A0 =A0 =A0 11 =A0 =A0 =A019 =A0 =A0 =A023 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0
> =A0 =A0 =A02008 =A0 =A0 =A0 3 =A0 =A0 =A0 15 =A0 =A0 =A00];
>
> I have the data for November 2007 with hourly data, then I have data for =
March 2008 with hourly data. How do I interpolate between the hourly monthl=
y data to make it hourly data between November 2007 to March 2008?
>
> Thank you =A0 =A0 =A0 =A0 =A0 =A0 =A0

%  Convert your times to Matlab days:
t=3Ddatenum(A(:,1),A(:,2),A(,3),A(:,4),0,0);
%  Generate the new times at hourly intervals
tt=3D[t(1):1/24:t(end)]';
%  Interpolate
yy=3Dinterp1(t,y,tt);
```
 0

2 Replies
285 Views

Similiar Articles:

7/24/2012 11:55:46 AM