How to check the point in the plot is outlier in MatLab? - MatLab

 How to check the point in the plot is outlier in MatLab? - MatLab


How to check the point in the plot is outlier in MatLab?

[Ans]

isoutlier

[Syntax]

[Description]

find outliers in data.
outliers, outlier points, are  abnormal points.

In MatLab, by default, an outlier is a value that is more than 3 scaled MAD(median  absolute derivations) away from the median.

isoutlier(<A>) 
If A is a vector, it will calculate median of A and check each point in the vector is an outlier or not.
If A is a matrix or table, it will operate column by column of A.
i.e. it will operate every columns  of A. 
If A is a multi-dimension array, it will operate along the first dimension whose size is not equal to 1.

isoutlier(<A>, <methodName>)

It will call isoutlier(A) with specified method <methodName>.

For other usage, see the following website.



more details on:


code:
%isoutlier_example.m
clear
clc
%code that check some points is abnormal or not.
fprintf("Hello MatLab.");
%vector
A = [57 59 60 100 59 58 57 58 300 61 62 60 62 58 57];
TF = isoutlier(A)
fprintf("1\n");
A = [57 59 60 100 59 58 57 58 300 61 62 60 62 58 57];
TF = isoutlier(A,'mean')
fprintf("2\n");
x = -2*pi:0.1:2*pi;
A = sin(x);
A(47) = 0;
t = datetime(2017,1,1,0,0,0) + hours(0:length(x)-1);
TF = isoutlier(A,'movmedian',hours(5),'SamplePoints',t)
plot(t,A,t(TF),A(TF),'x');
%legend('Data','Outlier');
fprintf("3\n");
%matrix
A = magic(5) + diag(200*ones(1,5));
TF = isoutlier(A,2)
fprintf("4\n");
%vector
%plot
x = 1:10;
A = [60 59 49 49 58 100 61 57 48 58];
[TF,L,U,C] = isoutlier(A);
plot(x,A,x(TF),A(TF),'x',x,L*ones(1,10),x,U*ones(1,10),x,C*ones(1,10))
%legend('Original Data','Outlier','Lower Threshold','Upper Threshold','Center Value');

Comments

Popular posts from this blog

How to hold plots in MatLab? - hold -- MatLab

How to check whether point is changed or not in MatLab? - ischange -- MatLab

Data distribution plots in MatLab -- MatLab