On Tue, Aug 14, 2012 at 1:53 PM, Carnë Draug wrote: > On 9 August 2012 03:11, Mike Miller <mtmil...@ieee.org> wrote: >> >> Finally got back to this, it's now closer to what you showed here. >> It's clear that Matlab is forcing the 4th argument to always be a >> power of 2, even though that's not in the help text. I implemented >> that, added an error message for the case of the argument being too >> small (after conversion to a power of 2), and added a test case based >> on your examples above. Thanks for those! > > Hi Mike > > I have just noticed that this introduced another bug (which I think > was already there before, this just made it more apparent. For > example, if the minimum value for 4th argument is more than the > default, it also automatically (and silently) increases though I'm not > sure for how much. For example:
Thanks for checking, I'll take a look at this again today when I get back to my dev box. >>> f = [0 0.1 0.1 0.2 0.2 1]; m = [0 0 1 1 0 0]; >>> bdef = fir2(1024, f, m); > > should make the 4th argument default to 512 which would be too low and > return an error (current behaviour with Octave). However, this does > not happen in Matlab. But if the default value is specified, then it > gives an error. And it doesn't default to the next possible value > (1024) as I first expected, it defaults to 2048. > > [...] > > Let me know if you need more tests. Yes, can you repeat your tests using 1023 and 2047 instead? The limit is calculated based on the length of the filter which is order+1, I think that's why you're seeing it go up to the next power of two. bdef = fir2(1023, f, m); b512 = fir2(1023, f, m, 512); % should not error now b1024 = fir2(1023, f, m, 1024); isequal(bdef, b512) % should be true bdef = fir2(2047, f, m); b1024 = fir2(2047, f, m, 1024); isequal(bdef, b1024) % should be true If that's right should be an easy fix. Have you done any comparison of the actual resulting filter against what Matlab returns? If you have patience for any more, I can come up with some tests to verify the 5th argument too. -- mike ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Octave-dev mailing list Octave-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/octave-dev