From: <jo...@us...> - 2012-08-20 17:05:57
|
Revision: 10888 http://octave.svn.sourceforge.net/octave/?rev=10888&view=rev Author: jordigh Date: 2012-08-20 17:05:50 +0000 (Mon, 20 Aug 2012) Log Message: ----------- Style fixes in firls.m Modified Paths: -------------- trunk/octave-forge/main/signal/inst/firls.m Modified: trunk/octave-forge/main/signal/inst/firls.m =================================================================== --- trunk/octave-forge/main/signal/inst/firls.m 2012-08-19 22:32:59 UTC (rev 10887) +++ trunk/octave-forge/main/signal/inst/firls.m 2012-08-20 17:05:50 UTC (rev 10888) @@ -38,32 +38,32 @@ function coef = firls(N, frequencies, pass, weight, str); - if nargin<3 || nargin>6 + if (nargin < 3 || nargin > 6) print_usage; - elseif nargin==3 - weight = ones(1, length(pass)/2); + elseif (nargin == 3) + weight = ones (1, length(pass)/2); str = []; - elseif nargin==4 - if ischar(weight) + elseif (nargin == 4) + if ischar (weight) str = weight; weight = ones (size (pass)); else str = []; - end - end + endif + endif if length (frequencies) ~= length (pass) error("F and A must have equal lengths."); elseif 2 * length (weight) ~= length (pass) error("W must contain one weight per band."); - elseif ischar(str) + elseif ischar (str) error("This feature is implemented yet"); else M = N/2; - w = kron(weight(:), [-1; 1]); + w = kron (weight(:), [-1; 1]); omega = frequencies * pi; - i1 = 1:2:length(omega); - i2 = 2:2:length(omega); + i1 = 1:2:length (omega); + i2 = 2:2:length (omega); ## Generate the matrix Q ## As illustrated in the above-cited reference, the matrix can be @@ -94,8 +94,8 @@ ## - n ## cos_ints2 = [omega(i1).^2 - omega(i2).^2; ... - cos((1:M)' * omega(i2)) - cos((1:M)' * omega(i1))] ./ ... - ([2, 1:M]' * (omega(i2) - omega(i1))); + cos((1:M)' * omega(i2)) - cos((1:M)' * omega(i1))] ./ ... + ([2, 1:M]' * (omega(i2) - omega(i1))); d = [-weight .* pass(i1); weight .* pass(i2)] (:); b = [1, 1./(1:M)]' .* ((kron (cos_ints2, [1, 1]) + cos_ints(1:M+1,:)) * d); @@ -104,6 +104,6 @@ a = Q \ b; coef = [ a(end:-1:2); 2 * a(1); a(2:end) ]; - end + endif endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2012-08-20 17:11:06
|
Revision: 10889 http://octave.svn.sourceforge.net/octave/?rev=10889&view=rev Author: jordigh Date: 2012-08-20 17:10:59 +0000 (Mon, 20 Aug 2012) Log Message: ----------- firls.m: ensure N is even Modified Paths: -------------- trunk/octave-forge/main/signal/inst/firls.m Modified: trunk/octave-forge/main/signal/inst/firls.m =================================================================== --- trunk/octave-forge/main/signal/inst/firls.m 2012-08-20 17:05:50 UTC (rev 10888) +++ trunk/octave-forge/main/signal/inst/firls.m 2012-08-20 17:10:59 UTC (rev 10889) @@ -13,12 +13,12 @@ ## You should have received a copy of the GNU General Public License along with ## this program; if not, see <http://www.gnu.org/licenses/>. -## b = firls(N, F, A); -## b = firls(N, F, A, W); +## b = firls(N, F, A); b = firls(N, F, A, W); ## ## FIR filter design using least squares method. Returns a length N+1 ## linear phase filter such that the integral of the weighted mean -## squared error in the specified bands is minimized. +## squared error in the specified bands is minimized. N must be an even +## integer or ## ## F specifies the frequencies of the band edges, normalized so that ## half the sample frequency is equal to 1. Each band is specified by @@ -28,7 +28,8 @@ ## ## W is an optional weighting function that contains one value for each ## band that weights the mean squared error in that band. A must be the -## same length as F, and W must be half the length of F. +## same length as F, and W must be half the length of F. N must be +## even. If you specify an odd value, firls increments it by 1. ## ## The least squares optimization algorithm for computing FIR filter ## coefficients is derived in detail in: @@ -59,6 +60,8 @@ error("This feature is implemented yet"); else + N += mod (N, 2); + M = N/2; w = kron (weight(:), [-1; 1]); omega = frequencies * pi; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2012-08-20 17:15:36
|
Revision: 10890 http://octave.svn.sourceforge.net/octave/?rev=10890&view=rev Author: jordigh Date: 2012-08-20 17:15:30 +0000 (Mon, 20 Aug 2012) Log Message: ----------- firls.m: fix docstring Modified Paths: -------------- trunk/octave-forge/main/signal/inst/firls.m Modified: trunk/octave-forge/main/signal/inst/firls.m =================================================================== --- trunk/octave-forge/main/signal/inst/firls.m 2012-08-20 17:10:59 UTC (rev 10889) +++ trunk/octave-forge/main/signal/inst/firls.m 2012-08-20 17:15:30 UTC (rev 10890) @@ -13,12 +13,12 @@ ## You should have received a copy of the GNU General Public License along with ## this program; if not, see <http://www.gnu.org/licenses/>. -## b = firls(N, F, A); b = firls(N, F, A, W); +## b = firls(N, F, A); +## b = firls(N, F, A, W); ## ## FIR filter design using least squares method. Returns a length N+1 ## linear phase filter such that the integral of the weighted mean -## squared error in the specified bands is minimized. N must be an even -## integer or +## squared error in the specified bands is minimized. ## ## F specifies the frequencies of the band edges, normalized so that ## half the sample frequency is equal to 1. Each band is specified by @@ -29,7 +29,7 @@ ## W is an optional weighting function that contains one value for each ## band that weights the mean squared error in that band. A must be the ## same length as F, and W must be half the length of F. N must be -## even. If you specify an odd value, firls increments it by 1. +## even. If given an odd value, firls increments it by 1. ## ## The least squares optimization algorithm for computing FIR filter ## coefficients is derived in detail in: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |