How do I exclude anomalies from a plot in a data set?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
JJH
am 4 Jan. 2019
Bearbeitet: madhan ravi
am 4 Jan. 2019
I want to plot a data set and exclude anomalous points. Say I have some data, e.g.
x = [0.5 0.48 0.2 0.51 0.49 0.52]
y = [1 2 3 4 5 6]
and I want to do a linear fit to the data excluding the anomalous point (x = 0.2). I can currently get matlab to find anomalous points as follows:
plot(x,y,'.','color', CM(ij,:));
fitA = polyfit(x,y,1);
fdata = polyval(fitA,x);
I = abs(fdata - y) > 1.2*std(y);
outliers = excludedata(x,y,'indices',I);
but I then want to do another fit where I exclude the outlying points. I tried
fitB = polyfit(x,y,1,'Exclude',outliers);
but this gave the error:
Error using polyfit
Too many input arguments.
How can I do this second fit correctly?
0 Kommentare
Akzeptierte Antwort
madhan ravi
am 4 Jan. 2019
Bearbeitet: madhan ravi
am 4 Jan. 2019
https://www.mathworks.com/help/matlab/ref/polyfit.html - polyfit takes only three inputs
perhaps:
fitB(~ismember(fitB,outliers))
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!