0 <span class="keyword">if</span> nargin&lt;4; threshold=[]; <span class="keyword">end</span>
0021 <span class="keyword">if</span> nargin&lt;5; w=[]; <span class="keyword">end</span>
0022 
0023 [m,n,o]=size(x);
0024 
0025 <span class="comment">% offset of z relative to x</span>
0026 offset=max(0,-min(shifts));
0027 shifts=shifts+offset;           <span class="comment">% adjust shifts to make them nonnegative</span>
0028 idx=offset+(1:m-max(shifts));   <span class="comment">% x(idx) maps to z</span>
0029 
00