 m=1:length(degs)
    deg = degs(m);
    pp = preprocessorCreate(<span class="string">'rescaleX'</span>, true, <span class="string">'poly'</span>, deg, <span class="string">'addOnes'</span>, true);
    model = linregFit(xtrain, ytrain, <span class="string">'preproc'</span>, pp);
    ypredTrain = linregPredict(model, xtrain);
    ypredTest = linregPredict(model, xtest);
    mseTrain(m) = mean((ytrain-ypredTrain).^2);
    mseTest(m) = mean((ytest-ypredTest).^2);
<span class="keyword">end</span>

ndx = (degs&l