From: Eric Durant Subject: Bug in sosfilt() Date: 06 Jan 2000 00:00:00 GMT Message-ID: <3874F0F0.D238D3CB@umich.edu> Content-Transfer-Encoding: 7bit X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: news@eecs.umich.edu X-Trace: news.eecs.umich.edu 947188054 1089 141.213.12.216 (6 Jan 2000 19:47:34 GMT) Organization: University of Michigan Electrical Engineering & Computer Science Dept. Mime-Version: 1.0 NNTP-Posting-Date: 6 Jan 2000 19:47:34 GMT Newsgroups: comp.soft-sys.matlab The new sosfilt() function from the Signal Processing Toolbox in Matlab 5.3R11 seems to be broken. Instead of implementing a second order section, it simply scales the input data. Have I missed something, or is the function indeed broken? Please see the sample code below. ========== %%% Demonstrate bug in Matlab 5.3's sosfilt() % Eric Durant % Thursday 6 January 2000 % Verified on: % MATLAB Version 5.3.1.29215a (R11.1) on PCWIN % MATLAB Version 5.3.1.29215a (R11.1) on SOL2 % MATLAB Version 5.3.1.29215a (R11.1) on HP700 % Setup randn('state',sum(100*clock)); N = 10; b = randn(1,3); % IIR Filter Numerator a = randn(1,3); % IIR Filter Denominator x = randn(1,N); % Test Signal ba = [b a]; % Matlab SOS form; see sosfilt(), zp2sos(), etc. % The results from filter() and sosfilt() should be the same... yf = filter(b,a,x); ys = sosfilt(ba,x); % But they're not... fprintf(1,'The MSE (sosfilt<->filter) is %g.\n',mean((ys-yf).^2)); % In fact, sosfilt() merely scales the input... scale = b(1)/a(1); dif = (x*scale) - ys; fprintf(1,'The MSE (sosfilt<->scaled input) is %g.\n',mean(dif.^2)); ========== -- Eric Durant http://www.edurant.com/