function [y, m, b]=medmedline(x)
%function [y,m,b]=medmedline(x)
% This function implements the median-median line approximation
%to the n x 2 data points in x. The program will put x in the
%right format, so it can be input as n x 2 or 2 x n. The program
%will also sort the data, so the domain need not be sorted already.
%
% Output: y = n x 3 array, first column is domain, second
% column are the values on the median-median line
% and the third column is the set of residuals.
% m = slope of the median-median line
% b = intercept of the median-median line
%
%This method is most appropriate when the data has a few large
% errors, and the errors are in both domain and range.
%Get the matrix x in the desired format: Tall and ordered
[r,c]=size(x);
if r