On 9 August 2012 03:11, Mike Miller <mtmil...@ieee.org> wrote: > On Fri, Jul 27, 2012 at 10:14 AM, Carnë Draug wrote: >> On 6 July 2012 03:11, Mike Miller <mtmil...@ieee.org> wrote: >>> >>> The only thing that is not clear to me is whether this matches ML >>> behavior, and whether we care, e.g. if the caller passes in a 4th arg >>> too small, does ML generate an error or silently make it larger like >>> this line 29 does? >> >> MatLab gives an error in somes cases and silently makes it larger in others. >> >>>> f = [0 0.6 0.6 1]; m = [1 1 0 0]; >>>> b5 = fir2(30,f,m, 5); >> Error using fir2 (line 135) >> The number of grid points npt must be greater than or equal to 16 for >> filter order 30. >> >>>> b8 = fir2(30,f,m, 8); >> Error using fir2 (line 135) >> The number of grid points npt must be greater than or equal to 16 for >> filter order 30. >> >>>> b9 = fir2(30,f,m, 9); >>>> b15 = fir2(30,f,m, 15); >>>> b16 = fir2(30,f,m, 16); >>>> b17 = fir2(30,f,m, 17); >>>> isequal (b9, b15) >> >> ans = >> >> 1 >> >>>> isequal (b15, b16) >> >> ans = >> >> 1 >> >>>> isequal (b16, b17) >> >> ans = >> >> 0 >> >> >> Seems that MatLab behaviour is to adjust number of points (to the >> minimum), if the value is more than half of it and error otherwise. >> >> Not sure what's the best behavior but I'd guess at least a warning >> should be given. > > 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: >> 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. >> b512 = fir2(1024, f, m, 512); Error using fir2 (line 135) The number of grid points npt must be greater than or equal to 513 for filter order 1024. >> b1024 = fir2(1024, f, m, 1024); >> b2048 = fir2(1024, f, m, 2048); >> isequal (bdef, b1024) ans = 0 >> isequal (bdef, b2048) ans = 1 I don't know exactly what is used to calculate the defaults but seems to be the next above it. For example: >> bdef = fir2(2048, f, m); >> b2048 = fir2(2048, f, m, 2048); >> b4096 = fir2(2048, f, m, 4096); >> isequal (bdef, b2048) ans = 0 >> isequal (bdef, b4096) ans = 1 Let me know if you need more tests. Carnë ------------------------------------------------------------------------------ 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