% Runs the "BMD" example from the text. clear; clc; load BMDexample; %loads "age" and "bmd" as 169 x 1 vectors. N=200; %Number of points for the regression plot NumNbrs=20; x=linspace(min(age),max(age),N); for i=1:N [vals,idx]=sort(abs(x(i)-age)); y(i)=mean(bmd(idx(1:NumNbrs))); end plot(age,bmd,'k.',x,y,'r-');