From: joseph Frank on 14 Jan 2010 06:25 output = tsmovavg(tsobj, 's',Lag, dim) My vector of prices "Px" is a 2701x1 vector I want to compute the 30 days moving average using: output=tsmovavg(Px,'s',30) and I am receiving an error "lag must be scalar greater than 0 or less than the number of observations". I feel that I am misinterpreting the inputs that I need to use in the function. Any help is appreciated
From: ImageAnalyst on 14 Jan 2010 06:29 If it's as you say, then it looks right to me. The only thing I can think of is to include the last argument. Alternatively you can try the conv() function or the filter function.
From: Wayne King on 14 Jan 2010 06:35 "joseph Frank" <josephfrank1969(a)hotmail.com> wrote in message <himuug$rv3$1(a)fred.mathworks.com>... > output = tsmovavg(tsobj, 's',Lag, dim) > > My vector of prices "Px" is a 2701x1 vector > I want to compute the 30 days moving average using: > > output=tsmovavg(Px,'s',30) and I am receiving an error "lag must be scalar greater than 0 or less than the number of observations". I feel that I am misinterpreting the inputs that I need to use in the function. Any help is appreciated Hi Joseph, if you read the help documentation, tsmovavg() expects a row vector input. I'm assuming that Px is a real-valued data series, so just do: Px = Px'; %transpose it to a row vector that should work. Hope that helps, Wayne
From: Wayne King on 14 Jan 2010 06:38 "joseph Frank" <josephfrank1969(a)hotmail.com> wrote in message <himuug$rv3$1(a)fred.mathworks.com>... > output = tsmovavg(tsobj, 's',Lag, dim) > > My vector of prices "Px" is a 2701x1 vector > I want to compute the 30 days moving average using: > > output=tsmovavg(Px,'s',30) and I am receiving an error "lag must be scalar greater than 0 or less than the number of observations". I feel that I am misinterpreting the inputs that I need to use in the function. Any help is appreciated Sorry, just to add to my last post, if you want to leave Px as a column vector, you should be able to do output = tsmovavg(Px,'s',30,1); % this way it will work along the column dimension. Otherwise, tsmovavg uses a default dimension of 2 and operates along the row. Wayne
From: Oleg Komarov on 14 Jan 2010 06:41
"joseph Frank" > output = tsmovavg(tsobj, 's',Lag, dim) > > My vector of prices "Px" is a 2701x1 vector > I want to compute the 30 days moving average using: > > output=tsmovavg(Px,'s',30) and I am receiving an error "lag must be scalar greater than 0 or less than the number of observations". I feel that I am misinterpreting the inputs that I need to use in the function. Any help is appreciated Line 89 of tsmovavg uses size(tsobject), apparently the size doesn't return the right values: 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 |