Mercurial > hg > octave-lyh
changeset 1337:52a3f38cbfeb
[project @ 1995-08-25 02:00:18 by jwe]
author | jwe |
---|---|
date | Fri, 25 Aug 1995 02:16:01 +0000 |
parents | 33d5c2471c09 |
children | 3d235e3c13c0 |
files | scripts/control/c2d.m scripts/control/dare.m scripts/control/tzero.m scripts/elfun/gcd.m scripts/elfun/lcm.m scripts/general/postpad.m scripts/general/prepad.m scripts/linear-algebra/kron.m scripts/miscellaneous/etime.m scripts/polynomial/conv.m scripts/polynomial/deconv.m scripts/polynomial/roots.m scripts/signal/fftfilt.m scripts/signal/filter.m scripts/signal/freqz.m |
diffstat | 15 files changed, 73 insertions(+), 65 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/control/c2d.m +++ b/scripts/control/c2d.m @@ -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);
--- a/scripts/control/dare.m +++ b/scripts/control/dare.m @@ -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;
--- a/scripts/control/tzero.m +++ b/scripts/control/tzero.m @@ -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");
--- a/scripts/elfun/gcd.m +++ b/scripts/elfun/gcd.m @@ -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
--- a/scripts/elfun/lcm.m +++ b/scripts/elfun/lcm.m @@ -29,7 +29,7 @@ if (nargin > 1) va_start; for k = 2:nargin; - a = [a, va_arg ()]; + a = [a, (va_arg ())]; endfor endif
--- a/scripts/general/postpad.m +++ b/scripts/general/postpad.m @@ -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
--- a/scripts/general/prepad.m +++ b/scripts/general/prepad.m @@ -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
--- a/scripts/linear-algebra/kron.m +++ b/scripts/linear-algebra/kron.m @@ -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
--- a/scripts/miscellaneous/etime.m +++ b/scripts/miscellaneous/etime.m @@ -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;
--- a/scripts/polynomial/conv.m +++ b/scripts/polynomial/conv.m @@ -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
--- a/scripts/polynomial/deconv.m +++ b/scripts/polynomial/deconv.m @@ -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);
--- a/scripts/polynomial/roots.m +++ b/scripts/polynomial/roots.m @@ -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);
--- a/scripts/signal/fftfilt.m +++ b/scripts/signal/fftfilt.m @@ -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);