[slope,intercept] = RLINFIT(x,y) returns the coefficient estimates (slope and intercept) for a robust linear regression of the responses in y on the predictors in x.
RLINFIT uses the Theil-Sen method where the slope is given by the median of the slopes (yj-yi)/(xj-xi) determined by all pairs of sample points.
Since RLINFIT uses all pairs of sample points, this technique can be slow with large samples:
[...] = RLINFIT(x,y,P) uses only P percent of the total number of points to determine the coefficients. The points are selected randomly. P must be in ]0;100].
x = linspace(0,1,100);
y = 100*x+100 + randn(1,100)*10;
I = randperm(50);
y(I(1:15)) = 200+rand(1,15)*100;
[a,b] = rlinfit(x,y);
p = polyfit(x,y,1);
xi = [0 1];