Why do I receive NaN values with the tsmovavg function from Financial Toolbox 5.6?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Matthew Hong
le 2 Nov 2015
Réponse apportée : Nitin Khola
le 4 Nov 2015
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.
0 commentaires
Réponse acceptée
Nitin Khola
le 4 Nov 2015
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!