Why do I receive NaN values with the tsmovavg function from Financial Toolbox 5.6?

1 次查看(过去 30 天)
I am currently running into the issue where the first set of values within the length of the moving average window is assigned as NaN. I believe this issue is of similar nature to a different post http://www.mathworks.com/matlabcentral/answers/92471-why-do-i-receive-nan-values-when-i-use-the-tsmovavg-function-in-the-financial-time-series-toolbox-2 but with Financial Toolbox 5.6 rather than Financial Time Series Toolbox 2.1. I am running R2015b with the trial version of the Financial Toolbox 5.6.

采纳的回答

Nitin Khola
Nitin Khola 2015-11-4
Hi Matthew,
This is expected behavior. In the Answers post you mentioned in your question, the reason for such a behavior has been explained. I quote from the same post,
"The TSMOVAVG function computes the moving average using a moving window. If the length of the moving average is "n", then, when computing the first n-1 moving average values, the moving averages depend on data before the first available data sample. Therefore, TSMOVAVG treats these moving averages as undefined and assigns NaN values."
This is also illustrated by the first example in the documentation. Refer to the following link to access it: http://www.mathworks.com/help/finance/tsmovavg.html#examples
The first 13 elements of the resultant vector have been displayed below. Note that for the first 11 elements, the value is NaN.
>> simple
simple =
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
20.6320
20.6077

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by