Error in MATLAB median inside isoutlier function

6 ビュー (過去 30 日間)
noquinhas
noquinhas 2019 年 7 月 9 日
コメント済み: noquinhas 2019 年 7 月 10 日
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 件のコメント
noquinhas
noquinhas 2019 年 7 月 10 日
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.

サインインしてコメントする。

採用された回答

Steven Lord
Steven Lord 2019 年 7 月 9 日
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 件のコメント
noquinhas
noquinhas 2019 年 7 月 10 日
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!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by