# HG changeset patch # User jwe # Date 809316961 0 # Node ID 52a3f38cbfeb41f9714fc304eec7401022622274 # Parent 33d5c2471c09b3f625daa141697dd1e61c8aac5c [project @ 1995-08-25 02:00:18 by jwe] diff -r 33d5c2471c09 -r 52a3f38cbfeb scripts/control/c2d.m --- a/scripts/control/c2d.m Fri Aug 25 01:53:42 1995 +0000 +++ b/scripts/control/c2d.m Fri Aug 25 02:16:01 1995 +0000 @@ -49,7 +49,7 @@ error ("c2d: Ac and Bc must have the same number of rows"); endif - matexp = expm ([[Ac, Bc] * T; zeros (nb, na+nb)]); + matexp = expm ([[Ac, Bc] * T; (zeros (nb, na+nb))]); Ad = matexp (1:na, 1:na); Bd = matexp (1:na, na+1:na+nb); diff -r 33d5c2471c09 -r 52a3f38cbfeb scripts/control/dare.m --- a/scripts/control/dare.m Fri Aug 25 01:53:42 1995 +0000 +++ b/scripts/control/dare.m Fri Aug 25 02:16:01 1995 +0000 @@ -99,8 +99,8 @@ brb = (b/r)*b'; atc = a'\c; - [d, sy] = balance ([a + brb*atc, -brb/(a'); -atc, inv (a')], opt); - [u, s] = schur(sy,'D'); + [d, sy] = balance ([a + brb*atc, -brb/(a'); -atc, (inv (a'))], opt); + [u, s] = schur (sy, 'D'); u = d*u; n1 = n+1; n2 = 2*n; diff -r 33d5c2471c09 -r 52a3f38cbfeb scripts/control/tzero.m --- a/scripts/control/tzero.m Fri Aug 25 01:53:42 1995 +0000 +++ b/scripts/control/tzero.m Fri Aug 25 02:16:01 1995 +0000 @@ -41,20 +41,20 @@ warning ("tzero: number of inputs,outputs differ. squaring up"); if (p > m) warning (" by padding b and d with zeros."); - b = [b, zeros (n, p-m)]; - d = [d, zeros (p, p-m)]; + b = [b, (zeros (n, p-m))]; + d = [d, (zeros (p, p-m))]; m = p; else warning (" by padding c and d with zeros."); - c = [c; zeros (m-p, n)]; - d = [d; zeros (m-p, m)]; + c = [c; (zeros (m-p, n))]; + d = [d; (zeros (m-p, m))]; p = m; endif warning ("This is a kludge. Try again with SISO system."); endif ab = [-a, -b; c, d]; - bb = [eye (n), zeros (n, m); zeros (p, n), zeros (p, m)]; - [ab,bb] = balance (ab, bb); + bb = [(eye (n)), (zeros (n, m)); (zeros (p, n)), (zeros (p, m))]; + [ab, bb] = balance (ab, bb); zr = -qzval (ab, bb); else error ("tzero: a, b, c, d not compatible"); diff -r 33d5c2471c09 -r 52a3f38cbfeb scripts/elfun/gcd.m --- a/scripts/elfun/gcd.m Fri Aug 25 01:53:42 1995 +0000 +++ b/scripts/elfun/gcd.m Fri Aug 25 02:16:01 1995 +0000 @@ -31,7 +31,7 @@ if (nargin > 1) va_start; for k = 2:nargin; - a = [a, va_arg ()]; + a = [a, (va_arg ())]; endfor endif @@ -43,14 +43,14 @@ v = sign (a(1)); for k = 1:(length (a) - 1) x = [g, 1, 0]; - y = [abs (a(k+1)), 0, 1]; + y = [(abs (a(k+1))), 0, 1]; while (y(1) > 0) r = x - y * floor (x(1) / y(1)); x = y; y = r; endwhile g = x(1); - v = [x(2) * v, x(3) * sign (a(k+1))]; + v = [x(2) * v, x(3) * (sign (a(k+1)))]; endfor endfunction diff -r 33d5c2471c09 -r 52a3f38cbfeb scripts/elfun/lcm.m --- a/scripts/elfun/lcm.m Fri Aug 25 01:53:42 1995 +0000 +++ b/scripts/elfun/lcm.m Fri Aug 25 02:16:01 1995 +0000 @@ -29,7 +29,7 @@ if (nargin > 1) va_start; for k = 2:nargin; - a = [a, va_arg ()]; + a = [a, (va_arg ())]; endfor endif diff -r 33d5c2471c09 -r 52a3f38cbfeb scripts/general/postpad.m --- a/scripts/general/postpad.m Fri Aug 25 01:53:42 1995 +0000 +++ b/scripts/general/postpad.m Fri Aug 25 02:16:01 1995 +0000 @@ -1,10 +1,11 @@ -function y = postpad(x,l,c) +function y = postpad (x, l, c) -# postpad(x,l) +# postpad (x, l) +# # Appends zeros to the vector x until it is of length l. -# postpad(x,l,c) appends the constant c instead of zero. +# postpad (x, l, c) appends the constant c instead of zero. # -# If length(x) > l, elements from the end of x are removed +# If length (x) > l, elements from the end of x are removed # until a vector of length l is obtained. # Author: @@ -12,31 +13,33 @@ # amr@mpl.ucsd.edu # June 1994 - if(nargin == 2) + if (nargin == 2) c = 0; - elseif(nargin<2 || nargin>3) - usage ("postpad(x,l) or postpad(x,l,c)"); + elseif (nargin < 2 || nargin > 3) + usage ("postpad (x, l) or postpad (x, l, c)"); endif - if(is_matrix(x)) - error("first argument must be a vector"); - elseif(!is_scalar(l)) - error("second argument must be a scaler"); + if (is_matrix (x)) + error ("first argument must be a vector"); + elseif (! is_scalar (l)) + error ("second argument must be a scaler"); endif - if(l<0) - error("second argument must be non-negative"); + if (l < 0) + error ("second argument must be non-negative"); endif - lx = length(x); + lx = length (x); - if(lx >= l) + if (lx >= l) y = x(1:l); else - if(rows(x)>1) - y = [ x; c*ones(l-lx,1) ]; + if (rows (x) > 1) + tmp = c * ones (l-lx, 1); + y = [x; tmp]; else - y = [ x c*ones(1,l-lx) ]; + tmp = c * ones (1, l-lx); + y = [x, tmp]; endif endif diff -r 33d5c2471c09 -r 52a3f38cbfeb scripts/general/prepad.m --- a/scripts/general/prepad.m Fri Aug 25 01:53:42 1995 +0000 +++ b/scripts/general/prepad.m Fri Aug 25 02:16:01 1995 +0000 @@ -1,42 +1,45 @@ -function y = prepad(x,l,c) -#prepad(x,l) -#Prepends zeros to the vector x until it is of length l. -#prepad(x,l,c) prepends the constant c instead of zero. +function y = prepad (x, l, c) + +# prepad (x, l) # -#If length(x) > l, elements from the beginning of x are removed -#until a vector of length l is obtained. +# Prepends zeros to the vector x until it is of length l. +# prepad(x,l,c) prepends the constant c instead of zero. +# +# If length (x) > l, elements from the beginning of x are removed +# until a vector of length l is obtained. # Author: # Tony Richardson # amr@mpl.ucsd.edu # June 1994 - - if(nargin == 2) + if (nargin == 2) c = 0; - elseif(nargin<2 || nargin>3) - usage ("prepad(x,l) or prepad(x,l,c)"); + elseif (nargin < 2 || nargin > 3) + usage ("prepad (x, l) or prepad (x, l, c)"); endif - if(is_matrix(x)) - error("first argument must be a vector"); - elseif(!is_scalar(l)) - error("second argument must be a scaler"); + if (is_matrix (x)) + error ("first argument must be a vector"); + elseif (! is_scalar (l)) + error ("second argument must be a scaler"); endif - if(l<0) - error("second argument must be non-negative"); + if (l < 0) + error ("second argument must be non-negative"); endif - lx = length(x); + lx = length (x); - if(lx >= l) + if (lx >= l) y = x(lx-l+1:lx); else - if(rows(x)>1) - y = [ c*ones(l-lx,1); x ]; + if (rows (x) > 1) + tmp = c * ones (l-lx, 1); + y = [tmp; x]; else - y = [ c*ones(1,l-lx) x ]; + tmp = c * ones (1, l-lx); + y = [tmp, x]; endif endif diff -r 33d5c2471c09 -r 52a3f38cbfeb scripts/linear-algebra/kron.m --- a/scripts/linear-algebra/kron.m Fri Aug 25 01:53:42 1995 +0000 +++ b/scripts/linear-algebra/kron.m Fri Aug 25 02:16:01 1995 +0000 @@ -36,15 +36,17 @@ x = a (1, 1) * b; for ii = 2:ma - x = [x; a (ii, 1)*b]; + tmp = a (ii, 1) * b + x = [x; tmp]; endfor # Do remaining columns. for jj = 2:na - tmp = a (1, jj)*b; + tmp = a (1, jj) * b; for ii = 2:ma - tmp = [tmp; a (ii, jj)*b]; + pmt = a (ii, jj) * b; + tmp = [tmp; pmt]; endfor x = [x, tmp]; endfor diff -r 33d5c2471c09 -r 52a3f38cbfeb scripts/miscellaneous/etime.m --- a/scripts/miscellaneous/etime.m Fri Aug 25 01:53:42 1995 +0000 +++ b/scripts/miscellaneous/etime.m Fri Aug 25 02:16:01 1995 +0000 @@ -38,7 +38,7 @@ # XXX FIXME XXX -- could check here to ensure that t1 and t0 really do # make sense as vectors returned from clock(). - days_in_months = [31, 28, 31, 30, 31, 30 31, 31, 30, 31, 30, 31]; + days_in_months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; if (is_leap_year (t1 (1))) days_in_months (2) = days_in_months (2) + 1; diff -r 33d5c2471c09 -r 52a3f38cbfeb scripts/polynomial/conv.m --- a/scripts/polynomial/conv.m Fri Aug 25 01:53:42 1995 +0000 +++ b/scripts/polynomial/conv.m Fri Aug 25 02:16:01 1995 +0000 @@ -56,14 +56,14 @@ # Use the shortest vector as the coefficent vector to filter. if (la < lb) if (ly > lb) - x = [b, zeros (1, ly - lb)]; + x = [b, (zeros (1, ly - lb))]; else x = b; endif y = filter (a, 1, x); else if(ly > la) - x = [a, zeros (1, ly - la)]; + x = [a, (zeros (1, ly - la))]; else x = a; endif diff -r 33d5c2471c09 -r 52a3f38cbfeb scripts/polynomial/deconv.m --- a/scripts/polynomial/deconv.m Fri Aug 25 01:53:42 1995 +0000 +++ b/scripts/polynomial/deconv.m Fri Aug 25 02:16:01 1995 +0000 @@ -48,7 +48,7 @@ lb = ly - la + 1; if (ly > la) - b = filter (y, a, [1 zeros (1, ly - la)]); + b = filter (y, a, [1, (zeros (1, ly - la))]); elseif (ly == la) b = filter (y, a, 1); else @@ -61,7 +61,7 @@ if (ly == lc) r = y - conv (a, b); else - r = [ zeros(1, lc - ly) y] - conv (a, b); + r = [(zeros (1, lc - ly)), y] - conv (a, b); endif r = polyreduce (r); diff -r 33d5c2471c09 -r 52a3f38cbfeb scripts/polynomial/roots.m --- a/scripts/polynomial/roots.m Fri Aug 25 01:53:42 1995 +0000 +++ b/scripts/polynomial/roots.m Fri Aug 25 02:16:01 1995 +0000 @@ -49,7 +49,7 @@ A (1, :) = -v (2:l) ./ v (1); r = eig (A); if (f (m) < n) - r = [r; zeros(n - f(m), 1)]; + r = [r; (zeros(n - f(m), 1))]; endif else r = zeros (n - f(m), 1); diff -r 33d5c2471c09 -r 52a3f38cbfeb scripts/signal/fftfilt.m --- a/scripts/signal/fftfilt.m Fri Aug 25 01:53:42 1995 +0000 +++ b/scripts/signal/fftfilt.m Fri Aug 25 02:16:01 1995 +0000 @@ -41,7 +41,7 @@ [r_x, c_x] = size (x); [r_b, c_b] = size (b); - if (! (min ([r_x c_x]) == 1 || min ([r_b c_b]) == 1)) + if (! (min ([r_x, c_x]) == 1 || min ([r_b, c_b]) == 1)) error ("fftfilt: both x and b should be vectors"); endif l_x = r_x * c_x; @@ -65,7 +65,7 @@ if !(is_scalar (N)) error ("fftfilt: N has to be a scalar"); endif - N = 2^(ceil (log (max ([N l_b])) / log(2))); + N = 2^(ceil (log (max ([N, l_b])) / log(2))); L = N - l_b + 1; B = fft (b, N); R = ceil (l_x / L); diff -r 33d5c2471c09 -r 52a3f38cbfeb scripts/signal/filter.m --- a/scripts/signal/filter.m Fri Aug 25 01:53:42 1995 +0000 +++ b/scripts/signal/filter.m Fri Aug 25 02:16:01 1995 +0000 @@ -56,7 +56,7 @@ M = length(b); L = length(x); - MN = max([N M]); + MN = max([N, M]); lw = MN - 1; # It's convenient to pad the coefficient vectors to the same length. diff -r 33d5c2471c09 -r 52a3f38cbfeb scripts/signal/freqz.m --- a/scripts/signal/freqz.m Fri Aug 25 01:53:42 1995 +0000 +++ b/scripts/signal/freqz.m Fri Aug 25 02:16:01 1995 +0000 @@ -43,7 +43,7 @@ lb = length(b); b = reshape(b,1,lb); - k = max([la lb]); + k = max([la, lb]); if( n >= k) if (strcmp(region,"whole"))