Azzera filtri
Azzera filtri

Curve fitting tool - extract modified data

2 visualizzazioni (ultimi 30 giorni)
Anna Go
Anna Go il 24 Gen 2019
Modificato: Anna Go il 24 Gen 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)

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by