From: <sch...@us...> - 2010-07-02 14:18:46
|
Revision: 7463 http://octave.svn.sourceforge.net/octave/?rev=7463&view=rev Author: schloegl Date: 2010-07-02 14:18:40 +0000 (Fri, 02 Jul 2010) Log Message: ----------- support of 'bandpass' argument Modified Paths: -------------- trunk/octave-forge/main/signal/inst/fir1.m Modified: trunk/octave-forge/main/signal/inst/fir1.m =================================================================== --- trunk/octave-forge/main/signal/inst/fir1.m 2010-07-01 16:21:06 UTC (rev 7462) +++ trunk/octave-forge/main/signal/inst/fir1.m 2010-07-02 14:18:40 UTC (rev 7463) @@ -66,11 +66,11 @@ ## sort arglist, normalize any string for i=1:length(varargin) arg = varargin{i}; - if ischar(arg), arg=tolower(arg);end + if ischar(arg), arg=lower(arg);end if isempty(arg) continue; end # octave bug---can't switch on [] switch arg case {'low','stop','dc-1'}, ftype = 1; - case {'high','pass','dc-0'}, ftype = 0; + case {'high','pass','bandpass','dc-0'}, ftype = 0; case 'scale', scale = 1; case 'noscale', scale = 0; otherwise window = arg; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2011-11-10 19:43:11
|
Revision: 9051 http://octave.svn.sourceforge.net/octave/?rev=9051&view=rev Author: carandraug Date: 2011-11-10 19:43:04 +0000 (Thu, 10 Nov 2011) Log Message: ----------- fir1: bug fix submitted by Alberto Cuadrado <a.c...@gm...> on mailing list Modified Paths: -------------- trunk/octave-forge/main/signal/inst/fir1.m Modified: trunk/octave-forge/main/signal/inst/fir1.m =================================================================== --- trunk/octave-forge/main/signal/inst/fir1.m 2011-11-10 19:07:51 UTC (rev 9050) +++ trunk/octave-forge/main/signal/inst/fir1.m 2011-11-10 19:43:04 UTC (rev 9051) @@ -51,7 +51,7 @@ function b = fir1(n, w, varargin) if nargin < 2 || nargin > 5 - usage("b = fir1(n, w [, type] [, window] [, noscale])"); + print_usage; endif ## Assign default window, filter type and scale. @@ -59,9 +59,9 @@ ## create a lowpass filter. If multiple band edges, the first band ## defaults to a stop band so that the two band case defaults to a ## band pass filter. Ick. - window = []; - scale = 1; - ftype = (length(w)==1); + window = []; + scale = 1; + ftype = (length(w)==1); ## sort arglist, normalize any string for i=1:length(varargin) @@ -69,11 +69,11 @@ if ischar(arg), arg=lower(arg);end if isempty(arg) continue; end # octave bug---can't switch on [] switch arg - case {'low','stop','dc-1'}, ftype = 1; - case {'high','pass','bandpass','dc-0'}, ftype = 0; - case 'scale', scale = 1; - case 'noscale', scale = 0; - otherwise window = arg; + case {'low','stop','dc-1'}, ftype = 1; + case {'high','pass','bandpass','dc-0'}, ftype = 0; + case {'scale'}, scale = 1; + case {'noscale'}, scale = 0; + otherwise window = arg; end endfor @@ -96,11 +96,11 @@ ## Extend the window using interpolation M = length(window); if M == 1, - window = [window; window]; + window = [window; window]; elseif M < 4 - window = interp1(linspace(0,1,M),window,linspace(0,1,M+1),'linear'); + window = interp1(linspace(0,1,M),window,linspace(0,1,M+1),'linear'); else - window = interp1(linspace(0,1,M),window,linspace(0,1,M+1),'spline'); + window = interp1(linspace(0,1,M),window,linspace(0,1,M+1),'spline'); endif endif endif @@ -111,8 +111,18 @@ ## normalize filter magnitude if scale == 1 ## find the middle of the first band edge - if m(1) == 1, w_o = (f(2)-f(1))/2; - else w_o = f(3) + (f(4)-f(3))/2; + ## find the frequency of the normalizing gain + if m(1) == 1 + ## if the first band is a passband, use DC gain + w_o = 0; + elseif f(4) == 1 + ## for a highpass filter, + ## use the gain at half the sample frequency + w_o = 1; + else + ## otherwise, use the gain at the center + ## frequency of the first passband + w_o = f(3) + (f(4)-f(3))/2; endif ## compute |h(w_o)|^-1 @@ -140,4 +150,3 @@ %!assert(fir1(10,.5,'hanning','scale'), fir1(10,.5,'scale','hanning','low')); %!assert(fir1(10,.5,'haNNing','NOscale'), fir1(10,.5,'noscale','Hanning','LOW')); %!assert(fir1(10,.5,'boxcar',[]), fir1(10,.5,'boxcar')); - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-09-21 12:23:44
|
Revision: 11062 http://octave.svn.sourceforge.net/octave/?rev=11062&view=rev Author: carandraug Date: 2012-09-21 12:23:35 +0000 (Fri, 21 Sep 2012) Log Message: ----------- fir1: fix tests (checked with matlab that it should indeed return a row) Modified Paths: -------------- trunk/octave-forge/main/signal/inst/fir1.m Modified: trunk/octave-forge/main/signal/inst/fir1.m =================================================================== --- trunk/octave-forge/main/signal/inst/fir1.m 2012-09-21 07:39:42 UTC (rev 11061) +++ trunk/octave-forge/main/signal/inst/fir1.m 2012-09-21 12:23:35 UTC (rev 11062) @@ -140,9 +140,9 @@ %!demo %! freqz(fir1(15,[0.2, 0.5], 'stop', 'noscale')); -%!assert(fir1(2, .5, 'low', @hanning, 'scale'), [0 1 0]'); -%!assert(fir1(2, .5, 'low', "hanning", 'scale'), [0 1 0]'); -%!assert(fir1(2, .5, 'low', hanning(3), 'scale'), [0 1 0]'); +%!assert(fir1(2, .5, 'low', @hanning, 'scale'), [0 1 0]); +%!assert(fir1(2, .5, 'low', "hanning", 'scale'), [0 1 0]); +%!assert(fir1(2, .5, 'low', hanning(3), 'scale'), [0 1 0]); %!assert(fir1(10,.5,'noscale'), fir1(10,.5,'low','hamming','noscale')); %!assert(fir1(10,.5,'high'), fir1(10,.5,'high','hamming','scale')); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |