;
0029 <span class="keyword">end</span>
0030 
0031 
0032 <span class="comment">% offset of z relative to x</span>
0033 offset=max(0,-min(shifts));
0034 shifts=shifts+offset;           <span class="comment">% adjust shifts to make them nonnegative</span>
0035 idx=offset+(1:m-max(shifts));   <span class="comment">% x(idx) maps to z</span>
0036 
0037 <span class="comment">% % remove mean</span>
0038 <span class="comment">% x=nt_fold(nt_demean(nt_unfold(x),w),m);</span>
0039 
0040 <span class="comment">% covari