Error in MATLAB median inside isoutlier function
1 view (last 30 days)
Show older comments
I'm having the following error and I don't understand how to get around it. This error is on Matlab's function median when using isoutlier. My MATLAB's version is 2018b.
% Error message shown in Command Window
Error using median
Too many input arguments.
Error in locateoutliers (line 108)
center = median(a,1,'omitnan');
Error in isoutlier (line 144)
[tf, lthresh, uthresh, center] = locateoutliers(a, method, ...
I've been using this code for some time now and just recently I've been having this error. I've tried with the same data that worked before and I still obtain the same message now.
My code is basically organized in the following way:
% Data to analyze (may contain NaN)
rr = Peaks.r; % 1x900 double
% Find Outliers
out = isoutlier(rr);
When I open the line on MATLAB's intrinsic function:
% Where the error happens.
% This is MATLAB's function (obviously NOT written by me)
case 'median'
madfactor = -1 /(sqrt(2)*erfcinv(3/2)); %~1.4826
center = median(a,1,'omitnan');
amad = madfactor*median(abs(a - center), 1, 'omitnan');
lowerbound = center - p*amad;
upperbound = center + p*amad;
As I said earlier, the exact same code used to work. It's an error that is happening on MATLAB's function, so I don't know how to solve this.
I'm also havign a very similar problem with MATLAB's function normalize, and the error is on the function sum.
I didn't overwrite any function.
What can I do to fix this?
2 Comments
Adam Danz
on 9 Jul 2019
What version of matlab are you using (run ver())? Did the sympoms occur after changing matlab versions?
The 'omitnan' flag was introduced in r2015a. I'm wonering if an older version of matlab is accessing the median() function stored in newer release directory. This could happen if you manually moved files or added a path to a newer release directory (neither of which should ever happen).
Accepted Answer
Steven Lord
on 9 Jul 2019
You said you didn't overwrite any function, but did you download a function or a collection of functions or are you shadowing the functions in MATLAB? Let's check to make sure you're using the built-in sum function and the median function included in MATLAB.
which -all sum
which -all median
If you see versions of those functions outside of the matlabroot directory, rename or remove them. There will be multiple versions of those functions inside the matlabroot directory, many of which are in directories whose paths include the @ symbol. Leave those alone; don't rename or remove them.
3 Comments
Steven Lord
on 9 Jul 2019
Yes, all of the files in Adam Danz's listing are good. The first is the one used for numeric arrays and the others are the implementation of median for various types of objects.
More Answers (0)
See Also
Categories
Find more on Get Started with MATLAB 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!