User`s guide

excludedata
4-99
Remarks You can combine data exclusion methods using logical operators. For example,
to combine methods using the | (OR) operator
outliers = excludedata(xdata,ydata,'indices',[3 5]);
outliers = outliers|excludedata(xdata,ydata,'box',[1 10 0 90]);
In some cases, you might want to use the ~ (NOT) operator to specify a box that
contains all the data to exclude.
outliers = ~excludedata(xdata,ydata,'box',[1 10 0 90]);
Example Generate random data in the interval [0, 15], create a sine wave with noise, and
add two outliers with the value 2.
rand('state',0);
x = 15*rand(150,1);
y = sin(x) + (rand(size(x))-0.5)*0.5;
y(ceil(length(x)*rand(2,1))) = 2;
Identify outliers that are outside the interval [-1.5, 1.5] using the range
method.
outliers = excludedata(x,y,'range',[-1.5 1.5]);
Identify the same outliers using the indices method.
ind = find((y>1.5)|(y<-1.5));
outliers = excludedata(x,y,'indices',ind);
You can pass outliers to the fit function to exclude the specified data points
from a fit.
ftype = fittype('a*sin(b*x)');
fresult = fit(x,y,ftype,'startpoint',[1 1],'exclude',outliers);
See Also fit