error in nansum in financial toolbox

7 views (last 30 days)
carlwunsch
carlwunsch on 3 Nov 2016
Commented: Steven Lord on 4 Nov 2016
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 Comment
Brendan Hamm
Brendan Hamm on 3 Nov 2016
This should be in the Statistics and Machine Learning Toolbox. Is this included in your list of installed tools?

Sign in to comment.

Answers (3)

Steven Lord
Steven Lord on 3 Nov 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:
  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 on 3 Nov 2016
Thank you. It's a useful workaround. But removing nanmean, nansum, nanstd, etc from the basic Matlab was a serious mistake.
  3 Comments
carlwunsch
carlwunsch on 4 Nov 2016
Possibly correct. Should be in the basic Matlab. Combining "statistics" and "machine learning" is apples and oranges.
Steven Lord
Steven Lord on 4 Nov 2016
The functionality of nansum is now in base MATLAB. It's just named "the sum function called with the 'omitnan' flag."

Sign in to comment.


Jan
Jan on 4 Nov 2016
nansum can be simualted easily:
function S = mynansum(X, nargin);
X(isnan(X)) = 0;
S = sum(X, nargin{:});
end

Categories

Find more on Holidays / Seasons in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!