Error in MATLAB median inside isoutlier function

2 views (last 30 days)
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
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).
noquinhas
noquinhas on 10 Jul 2019
I haven't changed my version. I kept using Matlab 2018b.
I think it was just an issue with the kit I was using on my code. The weird part is that I've been using this kit for some time (never changed the version) and it always worked.

Sign in to comment.

Accepted Answer

Steven Lord
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
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.
noquinhas
noquinhas on 10 Jul 2019
Thank you all.
I found out that one MATLAB kit (this one) that I was using was probably causing the overwrite. When I checked all, I had all of these functions:
medianwarn.JPG
I re-installed the kit and now it seems that everything is working again.
It was weird because I've been using this kit and basically the same code for sometime already and never had any issues (it always ran without errors). I also didn't change my MATLAB's version.
I already posted a "bug"/"comment" on the kit github to see if I can go around this to not have an issue again.
Thank you!

Sign in to comment.

More Answers (0)

Categories

Find more on Startup and Shutdown 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!