I need to only plot the outliers that are out of my upper and lower limits. But I get a percentile error using TF= (A,'percentiles',threshold)
Below is my code and plot with out apply threshold to outlier.
XT{1} is a cell array of data.
%% Plot the control charts:
%For all the states (states 1, 3, 10, 12, 14), plot x(t), shown in blue in the hint below.
timev=zeros(1020,1);% initalize time vector
for i= 1:1020;
timev(i)= timev(i)+int*(8*(i)+30);
end
threshold=[LCL,UCL];
[TF]= isoutlier(XT{1},) %'percentiles',threshold)
%Create a new figure
figure('Renderer', 'painters', 'Position', [10 10 1200 900])
plot( timev, XT{1}, timev(TF),XT{1}(TF),'x')
hold on
%Plot the control limits CL, UCL, and LCL as horizontal lines in green. Remember that
%these limits are the same for all plots (calculated from state 1).
yline(CL,'g')% plot the control limits
yline(UCL,'g')% plot the upper control limits
yline(LCL,'g')% plot the lower control limits

 Akzeptierte Antwort

Star Strider
Star Strider am 29 Mai 2021

0 Stimmen

You have a typographical error. It should be 'percentiles', not 'percentile'.
From the documentation:
TF = isoutlier(A,'percentiles',threshold) defines outliers as points outside of the percentiles specified in threshold. The threshold argument is a two-element row vector containing the lower and upper percentile thresholds, such as [10 90].
.

4 Kommentare

Mande Hudson
Mande Hudson am 29 Mai 2021
Hi, yes I have tried percentiles but I get this error:
Error using isoutlier>parseinput (line 196)
Expected input number 2 to match one of these values:
'median', 'mean', 'quartiles', 'grubbs', 'gesd', 'movmedian', 'movmean', 'SamplePoints', 'DataVariables', 'ThresholdFactor', 'MaxNumOutliers'
The input, 'percentiles', did not match any of the valid values.
Error in isoutlier (line 90)
[method, wl, dim, p, sp, vars, maxoutliers] = parseinput(a, varargin);
Error in hudsonhwk9 (line 191)
TF= isoutlier(XT{1},'percentiles',threshold);
>>
The current documentation (and my reference) is for R2021a.
What version/release are you using?
The syntax works with R2021a
X{1} = rand(1, 100);
t = 1:numel(X{1});
TF = isoutlier(X{1},'percentiles',[20 80])
TF = 1×100 logical array
0 0 0 0 0 1 1 0 0 0 1 1 0 0 1 0 1 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 1 1 0 1 0 0 0 0 1 1 0 1 0 0 0 0 0
figure
plot(t,X{1})
hold on
plot(t(TF),X{1}(TF),'x')
yline(0.20)
yline(0.80)
hold off
grid
.
Mande Hudson
Mande Hudson am 29 Mai 2021
Im using R2018b
Please check the documentation for your version. The 'percentiles' option is not available in isoutlier in R2018b, however the prctile function is.
Instead, do something like this —
X{1} = rand(1, 100);
t = 1:numel(X{1});
p = prctile(X{:},[20 80])
p = 1×2
0.1945 0.7994
TF = (X{1}<=p(1)) | (X{1}>=p(2)) % Logical Index Of Values Outside The Respective Percentiles
TF = 1×100 logical array
1 1 1 0 0 0 0 1 0 1 0 1 0 1 1 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 1 1 1 0 1 1 0 0 1 1 0 0 0 0 0 0 1 0 1 0
figure
plot(t, X{1})
hold on
plot(t(TF), X{1}(TF),'x')
yline(0.2)
yline(0.8)
hold off
grid
That will identify them.
Then do whatever you want to with them after that.
.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Descriptive Statistics finden Sie in Hilfe-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