Home > NoiseTools > nt_multishift2.m

nt_multishift2

PURPOSE ^

z=nt_multishift2(x,nshifts) - apply multiple shifts/smoothing to matrix

SYNOPSIS ^

function z=nt_multishift2(x,nshifts)

DESCRIPTION ^

z=nt_multishift2(x,nshifts) - apply multiple shifts/smoothing to matrix

   y: result

   x: matrix to shift
   nshifts: number of shift terms
 
 X is shifted column by column (all shifts of 1st column, then all
 shifts of second column, etc).
 
 X may be 1D, 2D or 3D. See also convmtx.

 NoiseTools

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function z=nt_multishift2(x,nshifts)
0002 %z=nt_multishift2(x,nshifts) - apply multiple shifts/smoothing to matrix
0003 %
0004 %   y: result
0005 %
0006 %   x: matrix to shift
0007 %   nshifts: number of shift terms
0008 %
0009 % X is shifted column by column (all shifts of 1st column, then all
0010 % shifts of second column, etc).
0011 %
0012 % X may be 1D, 2D or 3D. See also convmtx.
0013 %
0014 % NoiseTools
0015 
0016 
0017 TBD
0018 
0019 
0020 if size(x,1)<max(shifts); error('shifts should be no larger than nrows'); end
0021 if min(shifts)<0; error('shifts should be nonnegative'); end
0022 shifts=shifts(:)';
0023 nshifts=numel(shifts);
0024 
0025 % array of shift indices
0026 N=size(x,1)-max(shifts); 
0027 shiftarray=nt_vecadd(nt_vecmult(ones(N,nshifts),shifts),(1:N)');
0028 [m,n,o]=size(x);
0029 z=zeros(N,n*nshifts,o);
0030 
0031 if ~isempty(amplitudes)
0032     amplitudes=amplitudes(:)';
0033     if numel(amplitudes)~=numel(shifts); error('amplitudes and shifts should have same numel'); end
0034     for k=1:o
0035         for j=0:n-1
0036             y=x(:,j+1,k);
0037             z(:,j*nshifts+1: j*nshifts+nshifts,k)=nt_vecmult(y(shiftarray),amplitudes);
0038         end
0039     end
0040 else
0041     for k=1:o
0042         for j=0:n-1
0043             y=x(:,j+1,k);
0044             z(:,j*nshifts+1: j*nshifts+nshifts,k)=y(shiftarray);
0045         end
0046     end
0047 end
0048

Generated on Mon 10-Nov-2014 14:40:42 by m2html © 2005