


symext.m
Symmetrically extends the input vector
Usage : xe = symext(x, ln, rn, par, sym)
x - vector to be extended, 1xN
ln - number of values to tack onto the left of x
rn - number of values to tack onto the right of x
par - parity of the extension,
'ee' or 'e' - repeating ext.,
'oo' or 'o' non-repeating,
'eo' - (2,1) extension (even on right, odd on left)
'oe' - (1,2) extension (odd on right, even on left)
sym - if par = 'e', sym gives whether we have a symmetric extension
(sym='s') or asymmetric (sym='a')
Written by : Justin Romberg
Created : 9/4/2001

0001 % symext.m 0002 % 0003 % Symmetrically extends the input vector 0004 % Usage : xe = symext(x, ln, rn, par, sym) 0005 % x - vector to be extended, 1xN 0006 % ln - number of values to tack onto the left of x 0007 % rn - number of values to tack onto the right of x 0008 % par - parity of the extension, 0009 % 'ee' or 'e' - repeating ext., 0010 % 'oo' or 'o' non-repeating, 0011 % 'eo' - (2,1) extension (even on right, odd on left) 0012 % 'oe' - (1,2) extension (odd on right, even on left) 0013 % 0014 % sym - if par = 'e', sym gives whether we have a symmetric extension 0015 % (sym='s') or asymmetric (sym='a') 0016 % 0017 % Written by : Justin Romberg 0018 % Created : 9/4/2001 0019 0020 function xe = symext(x, ln, rn, par, sym) 0021 0022 if (nargin < 5) 0023 sym = 's'; 0024 end 0025 0026 N = length(x); 0027 t = [fliplr(1-(1:ln)) 1:N N+1:N+rn]; 0028 if ((par == 'o') | (par == 'oo')) 0029 yl = 1; 0030 yh = N; 0031 elseif ((par == 'e') | (par == 'ee')) 0032 yl = 0.5; 0033 yh = N+0.5; 0034 elseif (par == 'eo') 0035 yl = 0.5; 0036 yh = N; 0037 elseif (par == 'oe') 0038 yl = 1; 0039 yh = N+0.5; 0040 end 0041 0042 if (abs(yl-yh)<1) 0043 tr = ones(1,ln+rn+1); 0044 else 0045 tr = zeros(size(t)); 0046 p = mod(floor((t-yl)/(yh-yl)),2); 0047 i0 = find(p == 0); 0048 tr(i0) = mod(t(i0)-yl, yh-yl) + yl; 0049 i1 = find(p == 1); 0050 tr(i1) = yh - mod(t(i1)-yl, yh-yl); 0051 end 0052 0053 tr = round(tr); 0054 if (sym == 'a') 0055 xe = (1-2*p).*x(tr); 0056 elseif (sym == 's') 0057 xe = x(tr); 0058 end