% Testrma.m   Feb. 2005 L Braile
% Test and plot the reduced major axis method for calculating the
% least squares straight line function with sample data
x = [1 2 3 4 5 6 7 8 9];
y = [1.5 1.8 2.0 3.6 4.1 6.8 6.4 4.0 9.4];
npts = length(x);
[a,b,sa,sb,r,p] = rma(x,y,npts) % Calculate and print
% least squares line and statistics for rma method 
% plot the data and least squares line
plot(x,y,'ro','markersize',12,'linewidth',3) % Plot the data
set(gca,'fontsize',16,'linewidth',2)
hold on
xlabel('x-values','fontsize',16)
ylabel('y-values','fontsize',16)
title('Plot of sample data and least squares straight line fit','fontsize',16)
yt = feval('sline',x,a,b); % Calculate the fitted line
plot(x,yt,'k-','linewidth',3) % Plot the fitted line
axis([0 10 0 10]); % Set axis limits for plot
hold off