Curve fitting tool - extract modified data

2 次查看(过去 30 天)
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)

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by