error in nansum in financial toolbox

7 Ansichten (letzte 30 Tage)
carlwunsch
carlwunsch am 3 Nov. 2016
Kommentiert: Steven Lord am 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 Kommentar
Brendan Hamm
Brendan Hamm am 3 Nov. 2016
This should be in the Statistics and Machine Learning Toolbox. Is this included in your list of installed tools?

Melden Sie sich an, um zu kommentieren.

Antworten (3)

Steven Lord
Steven Lord am 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 am 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 Kommentare
carlwunsch
carlwunsch am 4 Nov. 2016
Possibly correct. Should be in the basic Matlab. Combining "statistics" and "machine learning" is apples and oranges.
Steven Lord
Steven Lord am 4 Nov. 2016
The functionality of nansum is now in base MATLAB. It's just named "the sum function called with the 'omitnan' flag."

Melden Sie sich an, um zu kommentieren.


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

Kategorien

Mehr zu Holidays / Seasons finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by