error in nansum in financial toolbox
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Here's a series of commands and responses:
>> clear all; close all >> sum([1,2,3]) ans = 6 >> sum([1,2,3,NaN],'omitnan') ans = 6 >> nansum([1,2,3]) Undefined function 'nansum' for input arguments of type 'double'. >> nansum([1,2,3,NaN]) Undefined function 'nansum' for input arguments of type 'double'. >> >> which nansum C:\Program Files\MATLAB\R2016a\toolbox\finance\ftseries\@fints\nansum.m % fints method
Is this (non)functionality intended? I have nansum in dozens of codes that ran on older versions of Matlab. CW
>> ver ---------------------------------------------------------------------------------------------------- MATLAB Version: 9.0.0.341360 (R2016a) MATLAB License Number: ****** Operating System: Microsoft Windows 10 Pro Version 10.0 (Build 14393) Java Version: Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot™ 64-Bit Server VM mixed mode ---------------------------------------------------------------------------------------------------- MATLAB Version 9.0 (R2016a) Control System Toolbox Version 10.0 (R2016a) Curve Fitting Toolbox Version 3.5.3 (R2016a) Econometrics Toolbox Version 3.4 (R2016a) Excel Link Version 2.0 (R13) Filter Design HDL Coder Version 3.0 (R2016a) Financial Toolbox Version 5.7 (R2016a) GSW Oceanographic Toolbox Version 3.02 (R2011a) Global Optimization Toolbox ...
1 comentario
Brendan Hamm
el 3 de Nov. de 2016
This should be in the Statistics and Machine Learning Toolbox. Is this included in your list of installed tools?
Respuestas (3)
Steven Lord
el 3 de Nov. de 2016
There is a nansum function in Statistics and Machine Learning Toolbox that accepts regular numeric (including double precision) data.
There is a nansum function in Financial Toolbox that is called only when the first input is a fints (financial time series) object.
Based on the output of ver you posted, your installation includes Financial Toolbox but not Statistics and Machine Learning Toolbox. Therefore if you want to call nansum you can only call it with a fints object as the first input. Two ways to resolve this problem:
- If your license includes Statistics and Machine Learning Toolbox, install it. If it doesn't include this toolbox, purchase it then install it.
- Since you are using release R2016a, modify your code to call the sum function with the 'omitnan' flag. In case you need to consider compatibility, this flag was introduced in release R2015a and so this approach would work in that release or later of MATLAB.
0 comentarios
carlwunsch
el 3 de Nov. de 2016
3 comentarios
Steven Lord
el 4 de Nov. de 2016
The functionality of nansum is now in base MATLAB. It's just named "the sum function called with the 'omitnan' flag."
Jan
el 4 de Nov. de 2016
nansum can be simualted easily:
function S = mynansum(X, nargin);
X(isnan(X)) = 0;
S = sum(X, nargin{:});
end
0 comentarios
Ver también
Categorías
Más información sobre Holidays / Seasons en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!