Thread Subject:
NaN for time series collection

Subject: NaN for time series collection

From: Mads

Date: 31 May, 2012 08:05:13

Message: 1 of 6

Hi,

I have a time series collection with 57 periods and i want to resample to 60 periods instead. For the last 3 periods where i have no data i want the data points to be zero. As default they become NaN, is there a way to do this?

Thx

Subject: NaN for time series collection

From: Ben

Date: 31 May, 2012 14:40:11

Message: 2 of 6

"Mads" wrote in message <jq78np$aa4$1@newscl01ah.mathworks.com>...
> Hi,
>
> I have a time series collection with 57 periods and i want to resample to 60 periods instead. For the last 3 periods where i have no data i want the data points to be zero. As default they become NaN, is there a way to do this?
>
> Thx

try looking at the isnan function. (I also use logical indexing in this example, so that would be another googleable term for you to look into.)

%Setting up a test array
>>a = [1:60];
>>a(58:60)=NaN; %Change the last three to be NaNs

%Change all the NaNs in the data to be equal to zero
>>a(isnan(a))=0;

Subject: NaN for time series collection

From: Mads

Date: 31 May, 2012 14:52:07

Message: 3 of 6

Thank you for helping. You misunderstand my problem, though.

I have a collection of timeseries which are organized as a matlab timeseries collection (tscollection function). I want to apply an isnan-type function to this whole collection of time series.

"Ben" wrote in message <jq7vsb$gee$1@newscl01ah.mathworks.com>...
> "Mads" wrote in message <jq78np$aa4$1@newscl01ah.mathworks.com>...
> > Hi,
> >
> > I have a time series collection with 57 periods and i want to resample to 60 periods instead. For the last 3 periods where i have no data i want the data points to be zero. As default they become NaN, is there a way to do this?
> >
> > Thx
>
> try looking at the isnan function. (I also use logical indexing in this example, so that would be another googleable term for you to look into.)
>
> %Setting up a test array
> >>a = [1:60];
> >>a(58:60)=NaN; %Change the last three to be NaNs
>
> %Change all the NaNs in the data to be equal to zero
> >>a(isnan(a))=0;

Subject: NaN for time series collection

From: Ben

Date: 31 May, 2012 15:07:07

Message: 4 of 6

"Mads" wrote in message <jq80in$jsk$1@newscl01ah.mathworks.com>...
> Thank you for helping. You misunderstand my problem, though.
>
> I have a collection of timeseries which are organized as a matlab timeseries collection (tscollection function). I want to apply an isnan-type function to this whole collection of time series.

I haven't used tscollection before, but it just looks like a specific structure format -- right? So why won't isnan work for you by looping through the fields of the structure?

Subject: NaN for time series collection

From: Mads

Date: 31 May, 2012 15:30:17

Message: 5 of 6

It will and thats what i have done. But the timeseries collection object has a bunch of functions attached which operate on all timeseries in the collection, so i thought maybe someone would know how to use a tscollection operator to do this.


"Ben" wrote in message <jq81eq$npe$1@newscl01ah.mathworks.com>...
> "Mads" wrote in message <jq80in$jsk$1@newscl01ah.mathworks.com>...
> > Thank you for helping. You misunderstand my problem, though.
> >
> > I have a collection of timeseries which are organized as a matlab timeseries collection (tscollection function). I want to apply an isnan-type function to this whole collection of time series.
>
> I haven't used tscollection before, but it just looks like a specific structure format -- right? So why won't isnan work for you by looping through the fields of the structure?

Subject: NaN for time series collection

From: Ben

Date: 31 May, 2012 15:54:07

Message: 6 of 6

"Mads" wrote in message <jq82q9$11m$1@newscl01ah.mathworks.com>...
> It will and thats what i have done. But the timeseries collection object has a bunch of functions attached which operate on all timeseries in the collection, so i thought maybe someone would know how to use a tscollection operator to do this.
>

Hmm... well, if it works, don't break it!

Although, there are a few reasons I can come up with for why you'd want to do this: 1) you're unsatisfied with the speed of your implementation, 2) you want your code to be cleaner or 3) you want to learn a new function.

But since I haven't used timeseries before, I can't help. You could look at one of the other tools that Mathworks has written for you and take a crack at writing one of your own...

Good luck.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us