from weighted total least squares straight line fit by Mathias Anton
Calculates the parameters (and their uncertainties) to data with uncertainties in both coordinates

pearson_york_testdata.m
% script pearson_york_testdata.m
% see, e.g., Lybanon, M. in Am. J. Phys 52 (1), January 1984 
xin=[0,0.9,1.8,2.6,3.3,4.4,5.2,6.1,6.5,7.4];
wx=[1000,1000,500,800,200,80,60,20,1.8,1];
yin=[5.9,5.4,4.4,4.6,3.5,3.7,2.8,2.8,2.4,1.5];
wy=[1,1.8,4,8,20,20,70,70,100,500];
uxin=1./sqrt(wx);
uyin=1./sqrt(wy);

Contact us at files@mathworks.com