Effacer les filtres
Effacer les filtres

Curve fitting tool - extract modified data

2 vues (au cours des 30 derniers jours)
Anna Go
Anna Go le 24 Jan 2019
Modifié(e) : Anna Go le 24 Jan 2019
Hi everyone,
I'm using the curve fitting tool for linear regression and to remove outliers for my data.
Below is an example of what I'm trying to do.
How can I recieve the new data for y where the one outier identified has been removed?
Thanks
xdat = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10]
ydat = [ 100; 85; 66; 50; 40; 70; 25; 20; 15; 2]
%scatter(xdat,ydat)
f = fittype( 'poly1' );
% Fit model to data.
fit1 = fit( xdat, ydat, f);
% Link with code: https://de.mathworks.com/help/curvefit/removing-outliers.html
fdata = feval(fit1,xdat);
%Set standard deviation to 0.5
% Identifies outliers with deviation from baseline model
I = abs(fdata - ydat) > 0.5*std(ydat);
outliers = excludedata(xdat,ydat,'indices',I);
% refit model to data with outliers excluded
fit2 = fit(xdat,ydat,f, 'Exclude',outliers)

Réponses (0)

Catégories

En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by