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
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
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:
  1. If your license includes Statistics and Machine Learning Toolbox, install it. If it doesn't include this toolbox, purchase it then install it.
  2. 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.

carlwunsch
carlwunsch 2016-11-3
Thank you. It's a useful workaround. But removing nanmean, nansum, nanstd, etc from the basic Matlab was a serious mistake.
  3 个评论
carlwunsch
carlwunsch 2016-11-4
Possibly correct. Should be in the basic Matlab. Combining "statistics" and "machine learning" is apples and oranges.
Steven Lord
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
Jan 2016-11-4
nansum can be simualted easily:
function S = mynansum(X, nargin);
X(isnan(X)) = 0;
S = sum(X, nargin{:});
end

类别

Help CenterFile Exchange 中查找有关 Holidays / Seasons 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by