Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Using interp1 for timeseries data

Subject: Using interp1 for timeseries data

From: Yvonne

Date: 29 Apr, 2010 21:06:04

Message: 1 of 3

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

Subject: Using interp1 for timeseries data

From: Sean

Date: 29 Apr, 2010 21:37:04

Message: 2 of 3

"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.

Subject: Using interp1 for timeseries data

From: TideMan

Date: 29 Apr, 2010 23:07:05

Message: 3 of 3

On Apr 30, 9:06 am, "Yvonne " <h...@waikato.ac.nz> wrote:
> 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              

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

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us