error in nansum in financial toolbox
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
Brendan Hamm
2016-11-3
This should be in the Statistics and Machine Learning Toolbox. Is this included in your list of installed tools?
回答(3 个)
Steven Lord
2016-11-3
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 个评论
carlwunsch
2016-11-3
3 个评论
Steven Lord
2016-11-4
The functionality of nansum is now in base MATLAB. It's just named "the sum function called with the 'omitnan' flag."
Jan
2016-11-4
nansum can be simualted easily:
function S = mynansum(X, nargin);
X(isnan(X)) = 0;
S = sum(X, nargin{:});
end
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!