From: Wayne King on
"Oleg Komarov" <oleg.komarovRemove.this(a)hotmail.it> wrote in message <hinasv$fv7$1(a)fred.mathworks.com>...
> Loren Shure
> > >
> > > Px = timeseries(rand(100,1));
> > > size(Px)
> > > ans =
> > > 100 1
> > > Px = timeseries(rand(1,100));
> > > size(Px)
> > > ans =
> > > 100 1
> > >
> > > So i think there is a bug.
> > > If TMW can confirm...
> > >
> > > Oleg
> > >
> >
> > The first input to tsmovavg needs to be a timeseries object, not a
> > regular vector as Px seems to be. You'd need to place/convert Px to the
> > right class.
> >
> > --
> > Loren
> > http://blogs.mathworks.com/loren
>
> But Px is a timeseries obj:
>
> >> Px = timeseries(rand(100,1));
> >> isafin(Px,'timeseries')
> ans =
> 1
> >> size(Px)
> ans =
> 100 1
> >> size(Px.')
> ans =
> 100 1
> >> output = tsmovavg(Px, 's',30, 1)
> ??? Error using ==> tsmovavg>simplema at 238
> Lag must be scalar greater than 0 or less than the number of observations.
>
> Error in ==> tsmovavg at 98
> vout = simplema(vin, lag, vinVars, observ);
>
> As you can see the size function doesn't recognize more than 1 observations wheter the ts obj is a col vec or a row vec.
>
> Oleg

Hi Oleg (and others), it looks to me that tsmovavg() is designed to take either a vector (again it defaults to operate along the 2nd dimension, but can work on column vectors by specifying the dim argument as 1), or as an overloaded method to work on fints object (financial time series object). So that any of the following will work:

x = randn(100,1);
output = tsmovavg(x,'s',10,1);
output = tsmovavg(x','s',10);
dates =[today:today+99]';
tsobj = fints(dates,x);
output = tsmovavg(tsobj,'s',10);

Wayne
From: Oleg Komarov on
"Wayne King"
> > Loren Shure
> > > >
> > > > Px = timeseries(rand(100,1));
> > > > size(Px)
> > > > ans =
> > > > 100 1
> > > > Px = timeseries(rand(1,100));
> > > > size(Px)
> > > > ans =
> > > > 100 1
> > > >
> > > > So i think there is a bug.
> > > > If TMW can confirm...
> > > >
> > > > Oleg
> > > >
> > >
> > > The first input to tsmovavg needs to be a timeseries object, not a
> > > regular vector as Px seems to be. You'd need to place/convert Px to the
> > > right class.
> > >
> > > --
> > > Loren
> > > http://blogs.mathworks.com/loren
> >
> > But Px is a timeseries obj:
> >
> > >> Px = timeseries(rand(100,1));
> > >> isafin(Px,'timeseries')
> > ans =
> > 1
> > >> size(Px)
> > ans =
> > 100 1
> > >> size(Px.')
> > ans =
> > 100 1
> > >> output = tsmovavg(Px, 's',30, 1)
> > ??? Error using ==> tsmovavg>simplema at 238
> > Lag must be scalar greater than 0 or less than the number of observations.
> >
> > Error in ==> tsmovavg at 98
> > vout = simplema(vin, lag, vinVars, observ);
> >
> > As you can see the size function doesn't recognize more than 1 observations wheter the ts obj is a col vec or a row vec.
> >
> > Oleg
>
> Hi Oleg (and others), it looks to me that tsmovavg() is designed to take either a vector (again it defaults to operate along the 2nd dimension, but can work on column vectors by specifying the dim argument as 1), or as an overloaded method to work on fints object (financial time series object). So that any of the following will work:
>
> x = randn(100,1);
> output = tsmovavg(x,'s',10,1);
> output = tsmovavg(x','s',10);
> dates =[today:today+99]';
> tsobj = fints(dates,x);
> output = tsmovavg(tsobj,'s',10);
>
> Wayne
You're right.
I was misled by its name.
tsmovavvg is listed under the Financial toolbox while timeseries is included in the stadard package.

Anyway, the point is that
b = timeseries(rand(5, 4),'Name','LaunchData'); % example 1 from timeseries
size(b)
ans =
5 1

Should it be that way?

Oleg
From: Wayne King on
"Oleg Komarov" <oleg.komarovRemove.this(a)hotmail.it> wrote in message <hinebk$58h$1(a)fred.mathworks.com>...
> "Wayne King"
> > > Loren Shure
> > > > >
> > > > > Px = timeseries(rand(100,1));
> > > > > size(Px)
> > > > > ans =
> > > > > 100 1
> > > > > Px = timeseries(rand(1,100));
> > > > > size(Px)
> > > > > ans =
> > > > > 100 1
> > > > >
> > > > > So i think there is a bug.
> > > > > If TMW can confirm...
> > > > >
> > > > > Oleg
> > > > >
> > > >
> > > > The first input to tsmovavg needs to be a timeseries object, not a
> > > > regular vector as Px seems to be. You'd need to place/convert Px to the
> > > > right class.
> > > >
> > > > --
> > > > Loren
> > > > http://blogs.mathworks.com/loren
> > >
> > > But Px is a timeseries obj:
> > >
> > > >> Px = timeseries(rand(100,1));
> > > >> isafin(Px,'timeseries')
> > > ans =
> > > 1
> > > >> size(Px)
> > > ans =
> > > 100 1
> > > >> size(Px.')
> > > ans =
> > > 100 1
> > > >> output = tsmovavg(Px, 's',30, 1)
> > > ??? Error using ==> tsmovavg>simplema at 238
> > > Lag must be scalar greater than 0 or less than the number of observations.
> > >
> > > Error in ==> tsmovavg at 98
> > > vout = simplema(vin, lag, vinVars, observ);
> > >
> > > As you can see the size function doesn't recognize more than 1 observations wheter the ts obj is a col vec or a row vec.
> > >
> > > Oleg
> >
> > Hi Oleg (and others), it looks to me that tsmovavg() is designed to take either a vector (again it defaults to operate along the 2nd dimension, but can work on column vectors by specifying the dim argument as 1), or as an overloaded method to work on fints object (financial time series object). So that any of the following will work:
> >
> > x = randn(100,1);
> > output = tsmovavg(x,'s',10,1);
> > output = tsmovavg(x','s',10);
> > dates =[today:today+99]';
> > tsobj = fints(dates,x);
> > output = tsmovavg(tsobj,'s',10);
> >
> > Wayne
> You're right.
> I was misled by its name.
> tsmovavvg is listed under the Financial toolbox while timeseries is included in the stadard package.
>
> Anyway, the point is that
> b = timeseries(rand(5, 4),'Name','LaunchData'); % example 1 from timeseries
> size(b)
> ans =
> 5 1
>
> Should it be that way?
>
> Oleg
Apologies to all if we're getting off thread topic a bit:
It looks like size as a method returns the size of the object's Time property:

b = timeseries(rand(5, 4),'Name','LaunchData');
methods(b) % see size() as method
size(b) % same as size(b.Time)
but you can call the Matlab function size() directly on the value of the Data property
size(b.Data) % returns 5X4

Wayne

Wayne
From: Oleg Komarov on
> Apologies to all if we're getting off thread topic a bit:
> It looks like size as a method returns the size of the object's Time property:
>
> b = timeseries(rand(5, 4),'Name','LaunchData');
> methods(b) % see size() as method
> size(b) % same as size(b.Time)
> but you can call the Matlab function size() directly on the value of the Data property
> size(b.Data) % returns 5X4
>
> Wayne
Thanks Wayne. Now its clear.

Oleg