From: <car...@us...> - 2012-01-18 14:03:07
|
Revision: 9531 http://octave.svn.sourceforge.net/octave/?rev=9531&view=rev Author: carandraug Date: 2012-01-18 14:02:54 +0000 (Wed, 18 Jan 2012) Log Message: ----------- signal: * update GPL to v3 (or later) * fix copyright notices * use print_usage * fix indentation Modified Paths: -------------- trunk/octave-forge/main/signal/inst/__ellip_ws.m trunk/octave-forge/main/signal/inst/__ellip_ws_min.m trunk/octave-forge/main/signal/inst/arburg.m trunk/octave-forge/main/signal/inst/besself.m trunk/octave-forge/main/signal/inst/bilinear.m trunk/octave-forge/main/signal/inst/bitrevorder.m trunk/octave-forge/main/signal/inst/blackmanharris.m trunk/octave-forge/main/signal/inst/blackmannuttall.m trunk/octave-forge/main/signal/inst/bohmanwin.m trunk/octave-forge/main/signal/inst/boxcar.m trunk/octave-forge/main/signal/inst/buffer.m trunk/octave-forge/main/signal/inst/butter.m trunk/octave-forge/main/signal/inst/buttord.m trunk/octave-forge/main/signal/inst/cceps.m trunk/octave-forge/main/signal/inst/cheb.m trunk/octave-forge/main/signal/inst/cheb1ord.m trunk/octave-forge/main/signal/inst/cheb2ord.m trunk/octave-forge/main/signal/inst/chebwin.m trunk/octave-forge/main/signal/inst/cheby1.m trunk/octave-forge/main/signal/inst/cheby2.m trunk/octave-forge/main/signal/inst/chirp.m trunk/octave-forge/main/signal/inst/cmorwavf.m trunk/octave-forge/main/signal/inst/cohere.m trunk/octave-forge/main/signal/inst/convmtx.m trunk/octave-forge/main/signal/inst/cplxreal.m trunk/octave-forge/main/signal/inst/cpsd.m trunk/octave-forge/main/signal/inst/csd.m trunk/octave-forge/main/signal/inst/czt.m trunk/octave-forge/main/signal/inst/dct.m trunk/octave-forge/main/signal/inst/dct2.m trunk/octave-forge/main/signal/inst/dctmtx.m trunk/octave-forge/main/signal/inst/decimate.m trunk/octave-forge/main/signal/inst/dftmtx.m trunk/octave-forge/main/signal/inst/diric.m trunk/octave-forge/main/signal/inst/downsample.m trunk/octave-forge/main/signal/inst/dst.m trunk/octave-forge/main/signal/inst/dwt.m trunk/octave-forge/main/signal/inst/ellip.m trunk/octave-forge/main/signal/inst/ellipord.m trunk/octave-forge/main/signal/inst/fht.m trunk/octave-forge/main/signal/inst/filtfilt.m trunk/octave-forge/main/signal/inst/filtic.m trunk/octave-forge/main/signal/inst/fir1.m trunk/octave-forge/main/signal/inst/fir2.m Modified: trunk/octave-forge/main/signal/inst/__ellip_ws.m =================================================================== --- trunk/octave-forge/main/signal/inst/__ellip_ws.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/__ellip_ws.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, Modified: trunk/octave-forge/main/signal/inst/__ellip_ws_min.m =================================================================== --- trunk/octave-forge/main/signal/inst/__ellip_ws_min.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/__ellip_ws_min.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -22,14 +22,12 @@ ## ## - Serra, Celso Penteado, Teoria e Projeto de Filtros, Campinas: CARTGRAF, ## 1983. -## Author: Paulo Neis <p_...@ya...> function err=__ellip_ws_min(kl, x) -# -int=ellipke([kl; 1-kl]); -ql=int(1); -q=int(2); -err=abs((ql/q)-x); + int=ellipke([kl; 1-kl]); + ql=int(1); + q=int(2); + err=abs((ql/q)-x); endfunction Modified: trunk/octave-forge/main/signal/inst/arburg.m =================================================================== --- trunk/octave-forge/main/signal/inst/arburg.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/arburg.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ %% %% This program is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public License -%% as published by the Free Software Foundation; either version 2, +%% as published by the Free Software Foundation; either version 3, %% or (at your option) any later version. %% %% This program is distributed in the hope that it will be useful, Modified: trunk/octave-forge/main/signal/inst/besself.m =================================================================== --- trunk/octave-forge/main/signal/inst/besself.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/besself.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -1,5 +1,6 @@ -## Copyright (C) 2009 Thomas Sailer ## Copyright (C) 1999 Paul Kienzle <pki...@us...> +## Copyright (C) 2003 Doug Stewart <da...@sy...> +## Copyright (C) 2009 Thomas Sailer <t.s...@al...> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -44,9 +45,6 @@ ## Proakis & Manolakis (1992). Digital Signal Processing. New York: ## Macmillan Publishing Company. -## Author: Paul Kienzle <pki...@us...> -## Modified by: Doug Stewart <da...@sy...> Feb, 2003 - function [a, b, c, d] = besself (n, W, varargin) if (nargin>4 || nargin<2) || (nargout>4 || nargout<2) Modified: trunk/octave-forge/main/signal/inst/bilinear.m =================================================================== --- trunk/octave-forge/main/signal/inst/bilinear.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/bilinear.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -70,8 +70,6 @@ ## Proakis & Manolakis (1992). Digital Signal Processing. New York: ## Macmillan Publishing Company. -## Author: Paul Kienzle <pki...@us...> - function [Zz, Zp, Zg] = bilinear(Sz, Sp, Sg, T) if nargin==3 Modified: trunk/octave-forge/main/signal/inst/bitrevorder.m =================================================================== --- trunk/octave-forge/main/signal/inst/bitrevorder.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/bitrevorder.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -1,4 +1,4 @@ -## Copyright (C) 2007 Sylvain Pelissier <syl...@gm...> +## Copyright (C) 2007 Sylvain Pelissier <syl...@gm...> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{y} @var{i}] =} bitrevorder(@var{x}) -## Reorder x in the bit reversed order +## Reorder x in the bit reversed order ## @seealso{fft,ifft} ## @end deftypefn @@ -33,4 +33,4 @@ new_ind = bi2de(fliplr(de2bi(old_ind))); i = new_ind + 1; - y(old_ind+1) = x(i); \ No newline at end of file + y(old_ind+1) = x(i); Modified: trunk/octave-forge/main/signal/inst/blackmanharris.m =================================================================== --- trunk/octave-forge/main/signal/inst/blackmanharris.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/blackmanharris.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -1,4 +1,4 @@ -## Copyright (C) 2007 Sylvain Pelissier <syl...@gm...> +## Copyright (C) 2007 Sylvain Pelissier <syl...@gm...> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -15,22 +15,22 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{w}] =} blackmanharris(@var{L}) -## Compute the Blackman-Harris window. +## Compute the Blackman-Harris window. ## @seealso{rectwin, bartlett} ## @end deftypefn -function [w] = blackmanharris(L) - if (nargin < 1); usage('blackmanharris(x)'); end - if(! isscalar(L)) - error("L must be a number"); - endif - - N = L-1; - a0 = 0.35875; - a1 = 0.48829; - a2 = 0.14128; - a3 = 0.01168; - n = -ceil(N/2):N/2; - w = a0 + a1.*cos(2.*pi.*n./N) + a2.*cos(4.*pi.*n./N) + a3.*cos(6.*pi.*n./N); -endfunction; - \ No newline at end of file +function [w] = blackmanharris (L) + if (nargin < 1) + print_usage; + elseif(! isscalar(L)) + error("L must be a number"); + endif + + N = L-1; + a0 = 0.35875; + a1 = 0.48829; + a2 = 0.14128; + a3 = 0.01168; + n = -ceil(N/2):N/2; + w = a0 + a1.*cos(2.*pi.*n./N) + a2.*cos(4.*pi.*n./N) + a3.*cos(6.*pi.*n./N); +endfunction Modified: trunk/octave-forge/main/signal/inst/blackmannuttall.m =================================================================== --- trunk/octave-forge/main/signal/inst/blackmannuttall.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/blackmannuttall.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -1,4 +1,4 @@ -## Copyright (C) 2007 Muthiah Annamalai <mut...@ut...> +## Copyright (C) 2007 Muthiah Annamalai <mut...@ut...> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -15,22 +15,23 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{w}] =} blackmannuttall(@var{L}) -## Compute the Blackman-Nuttall window. +## Compute the Blackman-Nuttall window. ## @seealso{nuttallwin, kaiser} ## @end deftypefn function [w] = blackmannuttall(L) - if (nargin < 1); usage('blackmannuttall(L)'); end - if(! isscalar(L)) - error("L must be a number"); - endif - - N = L-1; - a0 = 0.3635819; - a1 = 0.4891775; - a2 = 0.1365995; - a3 = 0.0106411; - n = 0:N; - w = a0 - a1.*cos(2.*pi.*n./N) + a2.*cos(4.*pi.*n./N) - a3.*cos(6.*pi.*n./N); - w = w.'; -endfunction; + if (nargin < 1) + print_usage; + elseif (! isscalar(L)) + error("L must be a number"); + endif + + N = L-1; + a0 = 0.3635819; + a1 = 0.4891775; + a2 = 0.1365995; + a3 = 0.0106411; + n = 0:N; + w = a0 - a1.*cos(2.*pi.*n./N) + a2.*cos(4.*pi.*n./N) - a3.*cos(6.*pi.*n./N); + w = w.'; +endfunction Modified: trunk/octave-forge/main/signal/inst/bohmanwin.m =================================================================== --- trunk/octave-forge/main/signal/inst/bohmanwin.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/bohmanwin.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -1,4 +1,4 @@ -## Copyright (C) 2007 Sylvain Pelissier <syl...@gm...> +## Copyright (C) 2007 Sylvain Pelissier <syl...@gm...> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -15,38 +15,37 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{w}] =} bohmanwin(@var{L}) -## Compute the Bohman window of lenght L. +## Compute the Bohman window of lenght L. ## @seealso{rectwin, bartlett} ## @end deftypefn function [w] = bohmanwin(L) - if (nargin < 1); usage('bohmanwin(x)'); end - if(! isscalar(L)) - error("L must be a number"); - endif - - if(L < 0) - error('L must be positive'); - end - - if(L ~= floor(L)) - L = round(L); - warning('L rounded to the nearest integer.'); - end - - if(L == 0) - w = []; - - elseif(L == 1) - w = 1; - - else - N = L-1; - n = -N/2:N/2; - - w = (1-2.*abs(n)./N).*cos(2.*pi.*abs(n)./N) + (1./pi).*sin(2.*pi.*abs(n)./N); - w(1) = 0; - w(length(w))=0; - w = w'; - end -endfunction; \ No newline at end of file + if (nargin < 1) + print_usage + elseif(! isscalar(L)) + error("L must be a number"); + elseif(L < 0) + error('L must be positive'); + end + + if(L ~= floor(L)) + L = round(L); + warning('L rounded to the nearest integer.'); + end + + if(L == 0) + w = []; + + elseif(L == 1) + w = 1; + + else + N = L-1; + n = -N/2:N/2; + + w = (1-2.*abs(n)./N).*cos(2.*pi.*abs(n)./N) + (1./pi).*sin(2.*pi.*abs(n)./N); + w(1) = 0; + w(length(w))=0; + w = w'; + end +endfunction Modified: trunk/octave-forge/main/signal/inst/boxcar.m =================================================================== --- trunk/octave-forge/main/signal/inst/boxcar.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/boxcar.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -18,15 +18,13 @@ ## Returns the filter coefficients of a rectangular window of length n. function w = boxcar (n) - + if (nargin != 1) - usage ("w = boxcar(n)"); - endif - - if !isscalar(n) || n != floor(n) || n <= 0 + print_usage; + elseif !isscalar(n) || n != floor(n) || n <= 0 error ("boxcar: n must be an integer > 0"); endif w = ones(n, 1); - + endfunction Modified: trunk/octave-forge/main/signal/inst/buffer.m =================================================================== --- trunk/octave-forge/main/signal/inst/buffer.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/buffer.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, Modified: trunk/octave-forge/main/signal/inst/butter.m =================================================================== --- trunk/octave-forge/main/signal/inst/butter.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/butter.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -1,8 +1,10 @@ ## Copyright (C) 1999 Paul Kienzle <pki...@us...> +## Copyright (C) 2003 Doug Stewart <da...@sy...> +## Copyright (C) 2011 Alexander Klein <ale...@ma...> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -43,14 +45,10 @@ ## Proakis & Manolakis (1992). Digital Signal Processing. New York: ## Macmillan Publishing Company. -## Author: Paul Kienzle <pki...@us...> -## Modified by: Doug Stewart <da...@sy...> Feb, 2003 -## Tests and demos added: Alexander Klein <ale...@ma...>, Sep 2011 - function [a, b, c, d] = butter (n, W, varargin) if (nargin>4 || nargin<2) || (nargout>4 || nargout<2) - usage ("[b, a] or [z, p, g] or [a,b,c,d] = butter (n, W [, 'ftype'][,'s'])"); + print_usage; end ## interpret the input parameters @@ -59,7 +57,7 @@ end stop = 0; - digital = 1; + digital = 1; for i=1:length(varargin) switch varargin{i} case 's', digital = 0; Modified: trunk/octave-forge/main/signal/inst/buttord.m =================================================================== --- trunk/octave-forge/main/signal/inst/buttord.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/buttord.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -39,15 +39,12 @@ function [n, Wc] = buttord(Wp, Ws, Rp, Rs) if nargin != 4 - usage("[n, Wn] = buttord(Wp, Ws, Rp, Rs)"); - end - if length(Wp) != length(Ws) + print_usage; + elseif length(Wp) != length(Ws) error("buttord: Wp and Ws must have the same length"); - end - if length(Wp) != 1 && length(Wp) != 2 + elseif length(Wp) != 1 && length(Wp) != 2 error("buttord: Wp,Ws must have length 1 or 2"); - end - if length(Wp) == 2 && (all(Wp>Ws) || all(Ws>Wp) || diff(Wp)<=0 || diff(Ws)<=0) + elseif length(Wp) == 2 && (all(Wp>Ws) || all(Ws>Wp) || diff(Wp)<=0 || diff(Ws)<=0) error("buttord: Wp(1)<Ws(1)<Ws(2)<Wp(2) or Ws(1)<Wp(1)<Wp(2)<Ws(2)"); end @@ -83,4 +80,3 @@ Wc(stop) = 1-Wc(stop); endfunction - Modified: trunk/octave-forge/main/signal/inst/cceps.m =================================================================== --- trunk/octave-forge/main/signal/inst/cceps.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/cceps.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -22,13 +22,13 @@ ## Author: Andreas Weingessel <And...@ci...> ## Apr 1, 1994 ## Last modifified by AW on Nov 8, 1994 - + function cep = cceps (x, c) if (nargin == 1) c = 0; elseif (nargin != 2) - error ("usage: cceps (x [, correct])"); + print_usage; endif [nr, nc] = size (x); @@ -57,7 +57,7 @@ if (cor) F = fft (x(1:nr-1)) if (min (abs (F)) == 0) - error (bad_signal_message); + error (bad_signal_message); endif endif endif Modified: trunk/octave-forge/main/signal/inst/cheb.m =================================================================== --- trunk/octave-forge/main/signal/inst/cheb.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/cheb.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or (at +## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but @@ -25,22 +25,17 @@ ## If x is a vector, the output is a vector of the same size, where each ## element is calculated as y(i) = Tn(x(i)). -## Author: André Carezia <aca...@uo...> -## Description: Value of the Chebyshev polynomials - function T = cheb (n, x) if (nargin != 2) - usage ("cheb (n, x)"); - endif - - if !(isscalar (n) && (n == round(n)) && (n >= 0)) + print_usage; + elseif !(isscalar (n) && (n == round(n)) && (n >= 0)) error ("cheb: n has to be a positive integer"); endif if (max(size(x)) == 0) T = []; endif - # avoid resizing latencies + # avoid resizing latencies T = zeros(size(x)); ind = abs (x) <= 1; if (max(size(ind))) @@ -53,5 +48,4 @@ endif T = real(T); -end - +endfunction Modified: trunk/octave-forge/main/signal/inst/cheb1ord.m =================================================================== --- trunk/octave-forge/main/signal/inst/cheb1ord.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/cheb1ord.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -1,8 +1,9 @@ ## Copyright (C) 2000 Paul Kienzle <pki...@us...> +## Copyright (C) 2000 Laurent S. Mazet ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -12,8 +13,6 @@ ## ## You should have received a copy of the GNU General Public License ## along with this program; If not, see <http://www.gnu.org/licenses/>. -## -## Completed by: Laurent S. Mazet ## Compute chebyshev type I filter order and cutoff for the desired response ## characteristics. Rp is the allowable decibels of ripple in the pass @@ -34,13 +33,13 @@ function [n, Wc] = cheb1ord(Wp, Ws, Rp, Rs) if nargin != 4 - usage("[n, Wn] = cheb1ord(Wp, Ws, Rp, Rs)"); + print_usage; elseif length(Wp) != length(Ws) error("cheb1ord: Wp and Ws must have the same length"); elseif length(Wp) != 1 && length(Wp) != 2 error("cheb1ord: Wp,Ws must have length 1 or 2"); elseif length(Wp) == 2 && ... - (all(Wp>Ws) || all(Ws>Wp) || diff(Wp)<=0 || diff(Ws)<=0) + (all(Wp>Ws) || all(Ws>Wp) || diff(Wp)<=0 || diff(Ws)<=0) error("cheb1ord: Wp(1)<Ws(1)<Ws(2)<Wp(2) or Ws(1)<Wp(1)<Wp(2)<Ws(2)"); end Modified: trunk/octave-forge/main/signal/inst/cheb2ord.m =================================================================== --- trunk/octave-forge/main/signal/inst/cheb2ord.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/cheb2ord.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, Modified: trunk/octave-forge/main/signal/inst/chebwin.m =================================================================== --- trunk/octave-forge/main/signal/inst/chebwin.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/chebwin.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or (at +## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but @@ -48,21 +48,13 @@ ## ## See also: kaiser -## $Id$ -## -## Author: André Carezia <aca...@uo...> -## Description: Coefficients of the Dolph-Chebyshev window - function w = chebwin (n, at) if (nargin != 2) - usage ("chebwin (n, at)"); - endif - - if !(isscalar (n) && (n == round(n)) && (n > 0)) + print_usage; + elseif !(isscalar (n) && (n == round(n)) && (n > 0)) error ("chebwin: n has to be a positive integer"); - endif - if !(isscalar (at) && (at == real (at))) + elseif !(isscalar (at) && (at == real (at))) error ("chebwin: at has to be a real scalar"); endif @@ -94,5 +86,4 @@ endif w = w ./ max (w (:)); -end - +endfunction Modified: trunk/octave-forge/main/signal/inst/cheby1.m =================================================================== --- trunk/octave-forge/main/signal/inst/cheby1.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/cheby1.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -1,8 +1,9 @@ ## Copyright (C) 1999 Paul Kienzle <pki...@us...> +## Copyright (C) 2003 Doug Stewart <da...@sy...> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -42,13 +43,10 @@ ## Parks & Burrus (1987). Digital Filter Design. New York: ## John Wiley & Sons, Inc. -## Author: Paul Kienzle <pki...@us...> -## Modified: Doug Stewart Feb. 2003 - function [a,b,c,d] = cheby1(n, Rp, W, varargin) if (nargin>5 || nargin<3) || (nargout>4 || nargout<2) - usage ("[b, a] or [z, p, g] or [a,b,c,d]= cheby1 (n, Rp, W, [, 'ftype'][,'s'])"); + print_usage; endif ## interpret the input parameters Modified: trunk/octave-forge/main/signal/inst/cheby2.m =================================================================== --- trunk/octave-forge/main/signal/inst/cheby2.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/cheby2.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -1,8 +1,9 @@ ## Copyright (C) 1999 Paul Kienzle <pki...@us...> +## Copyright (C) 2003 Doug Stewart <da...@sy...> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -42,13 +43,10 @@ ## Parks & Burrus (1987). Digital Filter Design. New York: ## John Wiley & Sons, Inc. -## Author: Paul Kienzle <pki...@us...> -## Modified: Doug Stewart Feb. 2003 - function [a,b,c,d] = cheby2(n, Rs, W, varargin) if (nargin>5 || nargin<3) || (nargout>4 || nargout<2) - usage ("[b, a] or [z, p, g] or [a,b,c,d]= cheby2 (n, Rs, W, [, 'ftype'][,'s'])"); + print_usage; end ## interpret the input parameters Modified: trunk/octave-forge/main/signal/inst/chirp.m =================================================================== --- trunk/octave-forge/main/signal/inst/chirp.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/chirp.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -36,13 +36,10 @@ ## If you want a different sweep shape f(t), use the following: ## y = cos(2*pi*integral(f(t)) + 2*pi*f0*t + phase); -## 2001-08-31 Paul Kienzle <pki...@us...> -## * Fix documentation for quadratic case - function y = chirp(t, f0, t1, f1, form, phase) if nargin < 1 || nargin > 6 - usage("y = chirp(t [, f0 [, t1 [, f1 [, form [, phase]]]]])"); + print_usage; endif if nargin < 2, f0 = []; endif if nargin < 3, t1 = []; endif Modified: trunk/octave-forge/main/signal/inst/cmorwavf.m =================================================================== --- trunk/octave-forge/main/signal/inst/cmorwavf.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/cmorwavf.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -1,8 +1,8 @@ -## Copyright (C) 2007 Sylvain Pelissier <syl...@gm...> +## Copyright (C) 2007 Sylvain Pelissier <syl...@gm...> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -16,16 +16,15 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{psi,x}] =} cmorwavf (@var{lb,ub,n,fb,fc}) -## Compute the Complex Morlet wavelet. +## Compute the Complex Morlet wavelet. ## @end deftypefn function [psi,x] = cmorwavf (lb,ub,n,fb,fc) - if (nargin ~= 5); usage('[psi,x] = cmorwavf(lb,ub,n,fb,fc)'); end - - if (n <= 0 || floor(n) ~= n) - error("n must be an integer strictly positive"); - endif - x = linspace(lb,ub,n); - psi =((pi*fb)^(-0.5))*exp(2*i*pi*fc.*x).*exp(-x.^2/fb); + if (nargin ~= 5) + print_usage; + elseif (n <= 0 || floor(n) ~= n) + error("n must be an integer strictly positive"); + endif + x = linspace(lb,ub,n); + psi =((pi*fb)^(-0.5))*exp(2*i*pi*fc.*x).*exp(-x.^2/fb); endfunction - Modified: trunk/octave-forge/main/signal/inst/cohere.m =================================================================== --- trunk/octave-forge/main/signal/inst/cohere.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/cohere.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ %% %% This program is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public License -%% as published by the Free Software Foundation; either version 2, +%% as published by the Free Software Foundation; either version 3, %% or (at your option) any later version. %% %% This program is distributed in the hope that it will be useful, @@ -22,9 +22,7 @@ %% See "help pwelch" for description of arguments, hints and references %% --- especially hint (7) for Matlab R11 defaults. %% -%% - function [varargout] = cohere(varargin) %% if ( nargin<2 ) Modified: trunk/octave-forge/main/signal/inst/convmtx.m =================================================================== --- trunk/octave-forge/main/signal/inst/convmtx.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/convmtx.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -37,7 +37,7 @@ function b = convmtx (a, n) if (nargin != 2) - usage ("convmtx (a, n)"); + print_usage; endif [r, c] = size(a); Modified: trunk/octave-forge/main/signal/inst/cplxreal.m =================================================================== --- trunk/octave-forge/main/signal/inst/cplxreal.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/cplxreal.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ %% %% This program is free software; you can redistribute it and/or modify %% it under the terms of the GNU General Public License as published by -%% the Free Software Foundation; either version 2 of the License, or +%% the Free Software Foundation; either version 3 of the License, or %% (at your option) any later version. %% %% This program is distributed in the hope that it will be useful, Modified: trunk/octave-forge/main/signal/inst/cpsd.m =================================================================== --- trunk/octave-forge/main/signal/inst/cpsd.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/cpsd.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ %% %% This program is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public License -%% as published by the Free Software Foundation; either version 2, +%% as published by the Free Software Foundation; either version 3, %% or (at your option) any later version. %% %% This program is distributed in the hope that it will be useful, @@ -19,9 +19,7 @@ %% Estimate cross power spectrum of data "x" and "y" by the Welch (1967) %% periodogram/FFT method. %% See "help pwelch" for description of arguments, hints and references -%% - function [varargout] = cpsd(varargin) %% %% Check fixed argument Modified: trunk/octave-forge/main/signal/inst/csd.m =================================================================== --- trunk/octave-forge/main/signal/inst/csd.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/csd.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ %% %% This program is free software; you can redistribute it and/or %% modify it under the terms of the GNU General Public License -%% as published by the Free Software Foundation; either version 2, +%% as published by the Free Software Foundation; either version 3, %% or (at your option) any later version. %% %% This program is distributed in the hope that it will be useful, @@ -21,9 +21,7 @@ %% See "help pwelch" for description of arguments, hints and references %% --- especially hint (7) for Matlab R11 defaults. %% -%% - function [varargout] = csd(varargin) %% %% Check fixed argument Modified: trunk/octave-forge/main/signal/inst/czt.m =================================================================== --- trunk/octave-forge/main/signal/inst/czt.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/czt.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -44,7 +44,7 @@ ## multiply gg by M-elements of chirp and call it done function y = czt(x, m, w, a) - if nargin < 1 || nargin > 4, usage("y=czt(x, m, w, a)"); endif + if nargin < 1 || nargin > 4, print_usage; endif [row, col] = size(x); if row == 1, x = x(:); col = 1; endif Modified: trunk/octave-forge/main/signal/inst/dct.m =================================================================== --- trunk/octave-forge/main/signal/inst/dct.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/dct.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -54,13 +54,11 @@ ## ## Scaling the result by w(k)/2 will give us the desired output. -## Author: Paul Kienzle -## 2001-02-08 -## * initial release + function y = dct (x, n) if (nargin < 1 || nargin > 2) - usage ("y = dct(x [, n])"); + print_usage; endif realx = isreal(x); Modified: trunk/octave-forge/main/signal/inst/dct2.m =================================================================== --- trunk/octave-forge/main/signal/inst/dct2.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/dct2.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -20,14 +20,10 @@ ## Computes the 2-D DCT of x after padding or trimming rows to m and ## columns to n. -## Author: Paul Kienzle -## 2001-02-08 -## * initial revision - function y = dct2 (x, m, n) if (nargin < 1 || nargin > 3) - usage("dct (x) or dct (x, m, n) or dct (x, [m n])"); + print_usage; endif if nargin == 1 Modified: trunk/octave-forge/main/signal/inst/dctmtx.m =================================================================== --- trunk/octave-forge/main/signal/inst/dctmtx.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/dctmtx.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -14,7 +14,7 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## T = dctmtx (n) -## Return the DCT transformation matrix of size n x n. +## Return the DCT transformation matrix of size n x n. ## ## If A is an n x n matrix, then the following are true: ## T*A == dct(A), T'*A == idct(A) @@ -29,13 +29,9 @@ ## ## See also: dct, idct, dct2, idct2 -## Author: Paul Kienzle <pki...@us...> -## 2001-02-08 -## * initial release - function T = dctmtx(n) if nargin != 1 - usage("T = dctmtx(n)") + print_usage; endif if n > 1 Modified: trunk/octave-forge/main/signal/inst/decimate.m =================================================================== --- trunk/octave-forge/main/signal/inst/decimate.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/decimate.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -35,10 +35,11 @@ function y = decimate(x, q, n, ftype) - if nargin < 1 || nargin > 4, - usage("y=decimate(x, q [, n] [, ftype])"); + if nargin < 1 || nargin > 4 + print_usage; + elseif q != fix(q) + error("decimate only works with integer q."); endif - if q != fix(q), error("decimate only works with integer q."); endif if nargin<3 ftype='iir'; Modified: trunk/octave-forge/main/signal/inst/dftmtx.m =================================================================== --- trunk/octave-forge/main/signal/inst/dftmtx.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/dftmtx.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -26,13 +26,11 @@ function d = dftmtx(n) if (nargin != 1) - error ("usage: d = dftmtx (n)"); - endif - - if (!isscalar(n)) + print_usage; + elseif (!isscalar(n)) error ("dftmtx: argument must be scalar"); endif - + d = fft(eye(n)); endfunction Modified: trunk/octave-forge/main/signal/inst/diric.m =================================================================== --- trunk/octave-forge/main/signal/inst/diric.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/diric.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -1,8 +1,8 @@ -## Copyright (C) 2007 Sylvain Pelissier <syl...@gm...> +## Copyright (C) 2007 Sylvain Pelissier <syl...@gm...> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -15,18 +15,18 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{y}] =} diric(@var{x},@var{n}) -## Compute the dirichlet function. +## Compute the dirichlet function. ## @seealso{sinc, gauspuls, sawtooth} ## @end deftypefn function [y] = diric(x,n) - if (nargin < 2); usage('diric(x,n)'); end - - if (n <= 0 || floor(n) ~= n) - error("n must be an integer strictly positive"); - endif - - y = sin(n.*x./2)./(n.*sin(x./2)); - y(mod(x,2*pi)==0) = (-1).^((n-1).*x(mod(x,2*pi)==0)./(2.*pi)); + if (nargin < 2) + print_usage; + elseif (n <= 0 || floor(n) ~= n) + error("n must be an integer strictly positive"); + endif -endfunction; \ No newline at end of file + y = sin(n.*x./2)./(n.*sin(x./2)); + y(mod(x,2*pi)==0) = (-1).^((n-1).*x(mod(x,2*pi)==0)./(2.*pi)); + +endfunction Modified: trunk/octave-forge/main/signal/inst/downsample.m =================================================================== --- trunk/octave-forge/main/signal/inst/downsample.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/downsample.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -1,4 +1,4 @@ -## Copyright (C) 2007 Paul Kienzle <pki...@us...> +## Author: Paul Kienzle <pki...@us...> 2007 ## This function is public domain ## -*- texinfo -*- Modified: trunk/octave-forge/main/signal/inst/dst.m =================================================================== --- trunk/octave-forge/main/signal/inst/dst.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/dst.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -1,4 +1,4 @@ -## Copyright (C) 2006 Paul Kienzle <pki...@us...> +## Author: Paul Kienzle <pki...@us...> 2006 ## This function is public domain ## -*- texinfo -*- Modified: trunk/octave-forge/main/signal/inst/dwt.m =================================================================== --- trunk/octave-forge/main/signal/inst/dwt.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/dwt.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -1,4 +1,4 @@ -## Copyright (C) 2008 Sylvain Pelissier <syl...@gm...> +## Copyright (C) 2008 Sylvain Pelissier <syl...@gm...> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -15,19 +15,19 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{ca} @var{cd}] =} dwt(@var{x,lo_d,hi_d}) -## Comupte de discrete wavelet transform of x with one level. +## Comupte de discrete wavelet transform of x with one level. ## @end deftypefn +function [ca cd] = dwt(x,lo_d,hi_d) + if (nargin < 3|| nargin > 3) + print_usage; + elseif(~isvector(x) || ~isvector(lo_d) || ~isvector(hi_d)) + error('x, hi_d and lo_d must be vectors'); + end -function [ca cd] = dwt(x,lo_d,hi_d) - if (nargin < 3|| nargin > 3); usage("[ca cd] = dwt(x,lo_d,hi_d)"); end - - if(~isvector(x) || ~isvector(lo_d) || ~isvector(hi_d)) - error('x, hi_d and lo_d must be vectors'); - end - - h = filter(hi_d,1,x); - g = filter(lo_d,1,x); - - cd = downsample(h,2); - ca = downsample(g,2); \ No newline at end of file + h = filter(hi_d,1,x); + g = filter(lo_d,1,x); + + cd = downsample(h,2); + ca = downsample(g,2); +endfunction Modified: trunk/octave-forge/main/signal/inst/ellip.m =================================================================== --- trunk/octave-forge/main/signal/inst/ellip.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/ellip.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -1,8 +1,9 @@ ## Copyright (C) 2001 Paulo Neis <p_...@ya...> +## Copyright (C) 2003 Doug Stewart <da...@sy...> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -12,7 +13,6 @@ ## ## You should have received a copy of the GNU General Public License ## along with this program; If not, see <http://www.gnu.org/licenses/>. -## ## N-ellip 0.2.1 ##usage: [Zz, Zp, Zg] = ellip(n, Rp, Rs, Wp, stype,'s') @@ -47,15 +47,12 @@ ## - Parente Ribeiro, E., Notas de aula da disciplina TE498 - Processamento ## Digital de Sinais, UFPR, 2001/2002. ## - Kienzle, Paul, functions from Octave-Forge, 1999 (http://octave.sf.net). -## -## Author: Paulo Neis <p_...@ya...> -## Modified: Doug Stewart Feb. 2003 function [a,b,c,d] = ellip(n, Rp, Rs, W, varargin) if (nargin>6 || nargin<4) || (nargout>4 || nargout<2) - usage ("[b, a] or [z, p, g] or [a,b,c,d] = ellip (n, Rp, Rs, Wp, [, 'ftype'][,'s'])"); + print_usage; endif ## interpret the input parameters Modified: trunk/octave-forge/main/signal/inst/ellipord.m =================================================================== --- trunk/octave-forge/main/signal/inst/ellipord.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/ellipord.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -12,7 +12,6 @@ ## ## You should have received a copy of the GNU General Public License ## along with this program; If not, see <http://www.gnu.org/licenses/>. -## ## usage: [n,wp] = ellipord(wp,ws, rp,rs) ## @@ -27,70 +26,65 @@ ## - Lamar, Marcus Vinicius, Notas de aula da disciplina TE 456 - Circuitos ## Analogicos II, UFPR, 2001/2002. - - function [n, Wp] = ellipord(Wp, Ws, Rp, Rs) -## -[rp, cp]=size(Wp); -[rs, cs]=size(Ws); -if ( !(length(Wp)<=2 && (rp==1 || cp==1) && length(Ws)<=2 && (rs==1 || cs==1)) ) - error ("ellipord: frequency must be given as w0 or [w0, w1]"); -elseif (!all(Wp >= 0 & Wp <= 1 & Ws >= 0 & Ws <= 1)) ##### - error ("ellipord: critical frequencies must be in (0 1)"); -elseif (!(length(Wp)==1 || length(Wp) == 2 & length(Ws)==1 || length(Ws) == 2)) - error ("ellipord: only one filter band allowed"); -elseif (length(Wp)==2 && !(Wp(1) < Wp(2))) - error ("ellipord: first band edge must be smaller than second"); -elseif (length(Ws)==2 && !(length(Wp)==2)) - error ("ellipord: you must specify band pass borders."); -elseif (length(Wp)==2 && length(Ws)==2 && !(Ws(1) < Wp(1) && Ws(2) > Wp(2)) ) - error ("ellipord: ( Wp(1), Wp(2) ) must be inside of interval ( Ws(1), Ws(2) )"); -elseif (length(Wp)==2 && length(Ws)==1 && !(Ws < Wp(1) || Ws > Wp(2)) ) - error ("ellipord: Ws must be out of interval ( Wp(1), Wp(2) )"); -endif + [rp, cp]=size(Wp); + [rs, cs]=size(Ws); + if ( !(length(Wp)<=2 && (rp==1 || cp==1) && length(Ws)<=2 && (rs==1 || cs==1)) ) + error ("ellipord: frequency must be given as w0 or [w0, w1]"); + elseif (!all(Wp >= 0 & Wp <= 1 & Ws >= 0 & Ws <= 1)) ##### + error ("ellipord: critical frequencies must be in (0 1)"); + elseif (!(length(Wp)==1 || length(Wp) == 2 & length(Ws)==1 || length(Ws) == 2)) + error ("ellipord: only one filter band allowed"); + elseif (length(Wp)==2 && !(Wp(1) < Wp(2))) + error ("ellipord: first band edge must be smaller than second"); + elseif (length(Ws)==2 && !(length(Wp)==2)) + error ("ellipord: you must specify band pass borders."); + elseif (length(Wp)==2 && length(Ws)==2 && !(Ws(1) < Wp(1) && Ws(2) > Wp(2)) ) + error ("ellipord: ( Wp(1), Wp(2) ) must be inside of interval ( Ws(1), Ws(2) )"); + elseif (length(Wp)==2 && length(Ws)==1 && !(Ws < Wp(1) || Ws > Wp(2)) ) + error ("ellipord: Ws must be out of interval ( Wp(1), Wp(2) )"); + endif + # sampling frequency of 2 Hz + T = 2; + Wpw = tan(pi.*Wp./T); # prewarp + Wsw = tan(pi.*Ws./T); # prewarp + ##pass/stop band to low pass filter transform: + if (length(Wpw)==2 && length(Wsw)==2) + wp=1; + w02 = Wpw(1) * Wpw(2); # Central frequency of stop/pass band (square) + w3 = w02/Wsw(2); + w4 = w02/Wsw(1); + if (w3 > Wsw(1)) + ws = (Wsw(2)-w3)/(Wpw(2)-Wpw(1)); + elseif (w4 < Wsw(2)) + ws = (w4-Wsw(1))/(Wpw(2)-Wpw(1)); + else + ws = (Wsw(2)-Wsw(1))/(Wpw(2)-Wpw(1)); + endif + elseif (length(Wpw)==2 && length(Wsw)==1) + wp=1; + w02 = Wpw(1) * Wpw(2); + if (Wsw > Wpw(2)) + w3 = w02/Wsw; + ws = (Wsw - w3)/(Wpw(2) - Wpw(1)); + else + w4 = w02/Wsw; + ws = (w4 - Wsw)/(Wpw(2) - Wpw(1)); + endif + else + wp = Wpw; + ws = Wsw; + endif -# sampling frequency of 2 Hz -T = 2; + k=wp/ws; + k1=sqrt(1-k^2); + q0=(1/2)*((1-sqrt(k1))/(1+sqrt(k1))); + q= q0 + 2*q0^5 + 15*q0^9 + 150*q0^13; %(....) + D=(10^(0.1*Rs)-1)/(10^(0.1*Rp)-1); -Wpw = tan(pi.*Wp./T); # prewarp -Wsw = tan(pi.*Ws./T); # prewarp - -##pass/stop band to low pass filter transform: -if (length(Wpw)==2 && length(Wsw)==2) - wp=1; - w02 = Wpw(1) * Wpw(2); # Central frequency of stop/pass band (square) - w3 = w02/Wsw(2); - w4 = w02/Wsw(1); - if (w3 > Wsw(1)) - ws = (Wsw(2)-w3)/(Wpw(2)-Wpw(1)); - elseif (w4 < Wsw(2)) - ws = (w4-Wsw(1))/(Wpw(2)-Wpw(1)); - else - ws = (Wsw(2)-Wsw(1))/(Wpw(2)-Wpw(1)); - endif -elseif (length(Wpw)==2 && length(Wsw)==1) - wp=1; - w02 = Wpw(1) * Wpw(2); - if (Wsw > Wpw(2)) - w3 = w02/Wsw; - ws = (Wsw - w3)/(Wpw(2) - Wpw(1)); - else - w4 = w02/Wsw; - ws = (w4 - Wsw)/(Wpw(2) - Wpw(1)); - endif -else - wp = Wpw; - ws = Wsw; -endif - -k=wp/ws; -k1=sqrt(1-k^2); -q0=(1/2)*((1-sqrt(k1))/(1+sqrt(k1))); -q= q0 + 2*q0^5 + 15*q0^9 + 150*q0^13; %(....) -D=(10^(0.1*Rs)-1)/(10^(0.1*Rp)-1); - -n=ceil(log10(16*D)/log10(1/q)); + n=ceil(log10(16*D)/log10(1/q)); +endfunction Modified: trunk/octave-forge/main/signal/inst/fht.m =================================================================== --- trunk/octave-forge/main/signal/inst/fht.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/fht.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -12,7 +12,6 @@ ## ## You should have received a copy of the GNU General Public License ## along with this program; If not, see <http://www.gnu.org/licenses/>. -## ## -*- texinfo -*- ## @deftypefn{Function File} {m = } fht ( d, n, dim ) Modified: trunk/octave-forge/main/signal/inst/filtfilt.m =================================================================== --- trunk/octave-forge/main/signal/inst/filtfilt.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/filtfilt.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -4,7 +4,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -30,18 +30,6 @@ ## y = filtfilt(b,a,x); z = filter(b,a,x); % apply filter ## plot(t,x,';data;',t,y,';filtfilt;',t,z,';filter;') -## Changelog: -## 2000 02 pki...@us... -## - pad with zeros to load up the state vector on filter reverse. -## - add example -## 2007 12 po...@gn... -## - use filtic to compute initial and final states -## - work for multiple columns as well -## 2008 12 lc...@es... -## - fixed instability issues with IIR filters and noisy inputs -## - initial states computed according to Likhterov & Kopeika, 2003 -## - use of a "reflection method" to reduce end effects -## - added some basic tests ## TODO: (pkienzle) My version seems to have similar quality to matlab, ## but both are pretty bad. They do remove gross lag errors, though. @@ -49,7 +37,7 @@ function y = filtfilt(b, a, x) if (nargin != 3) - usage("y=filtfilt(b,a,x)"); + print_usage; end rotate = (size(x,1)==1); if rotate, # a row vector @@ -134,4 +122,3 @@ %! assert (y, [yr.' ys.']); %! y2 = filtfilt(b.', a.', [r.' s.']); %! assert (y, y2); - Modified: trunk/octave-forge/main/signal/inst/filtic.m =================================================================== --- trunk/octave-forge/main/signal/inst/filtic.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/filtic.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, @@ -35,12 +35,10 @@ ## input vector x and output vector y ## -## Author: David Billinghurst - function zf = filtic(b,a,y,x) if (nargin>4 || nargin<3) || (nargout>1) - usage ("zf = filtic (b, a, y [,x])"); + print_usage; endif if nargin < 4, x = []; endif Modified: trunk/octave-forge/main/signal/inst/fir1.m =================================================================== --- trunk/octave-forge/main/signal/inst/fir1.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/fir1.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -2,7 +2,7 @@ ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or +## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, Modified: trunk/octave-forge/main/signal/inst/fir2.m =================================================================== --- trunk/octave-forge/main/signal/inst/fir2.m 2012-01-18 08:20:01 UTC (rev 9530) +++ trunk/octave-forge/main/signal/inst/fir2.m 2012-01-18 14:02:54 UTC (rev 9531) @@ -1,17 +1,17 @@ ## Copyright (C) 2000 Paul Kienzle <pki...@us...> ## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. +## This program is free software; you can redistribute it and/or modify it under +## the terms of the GNU General Public License as published by the Free Software +## Foundation; either version 3 of the License, or (at your option) any later +## version. ## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. +## This program is distributed in the hope that it will be useful, but WITHOUT +## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +## details. ## -## You should have received a copy of the GNU General Public License -## along with this program; If not, see <http://www.gnu.org/licenses/>. +## You should have received a copy of the GNU General Public License along with +## this program; if not, see <http://www.gnu.org/licenses/>. ## usage: b = fir2(n, f, m [, grid_n [, ramp_n]] [, window]) ## @@ -43,19 +43,10 @@ ## [h, w] = freqz(fir2(100,f,m)); ## plot(f,m,';target response;',w/pi,abs(h),';filter response;'); -## Feb 27, 2000 PAK -## use ramping on any transition less than ramp_n units -## use 2^nextpow2(n+1) for expanded grid size if grid is too small -## 2001-01-30 PAK -## set default ramp length to grid_n/20 (i.e., pi/20 radians) -## use interp1 to interpolate the grid points -## better(?) handling of 0 and pi frequency points. -## added some demos - function b = fir2(n, f, m, grid_n, ramp_n, window) if nargin < 3 || nargin > 6 - usage("b = fir2(n, f, m [, grid_n [, ramp_n]] [, window])"); + print_usage; endif ## verify frequency and magnitude vectors are reasonable This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |