help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with function 'resample'


From: Mike Miller
Subject: Re: Problems with function 'resample'
Date: Thu, 13 Jun 2013 09:01:16 -0400

On Mon, Jun 10, 2013 at 21:25:38 -0500, Dmitri A. Sergatskov wrote:
> On Mon, Jun 10, 2013 at 8:06 PM, Terry Duell <address@hidden> wrote:
>>
>> Hello All,
>> I'm not sure if this is due to my use of 'resample', or a bug.
>> I have a signal (acc) , sampled at 2438.095535 Hz (variable Fs).
>> I would like to resample to 200 Hz, and use the following...
>>
>> [newacc,h] = resample(acc, 200, uint32(Fs));
>> and get the following error message...
>> warning: division by zero
>> error: resample: product: nonconformant arguments (op1 is 65535x1, op2 is
>> 65536x1)
>> error: called from:
>> error:   /home/terry/octave/signal-1.2.2/resample.m at line 82, column 6
>>
>> So thinking it might be an issue with difference between the real and
>> integer sample rates, I try...
>>
>> [newacc,h] = resample(acc, 200000000, 2438095535);
>> and get the following error message...
>> warning: division by zero
>> error: invalid range
>> error: called from:
>> error:   /home/terry/octave/signal-1.2.2/resample.m at line 66, column 6
>>
>> Is there a correct way to resample my signal to 200 Hz, or do we have a
>> bug?
>
>
> I think we have a bug. 'p' and 'q' in resample should be integer numbers
> (less than intmax) but represented
> by doubles.
> E.g.
> [newacc,h] = resample(acc, 2000, 24381);
> should work.

Another workaround would be to use fix(Fs) instead of uint32(Fs). Your
intent is to truncate the value, not treat it as an integer type.

I have fixed [1] this behavior in the resample function; the fixed
version will be in the next release of the signal package. You can
download the fixed m-file if needed in the meantime [2]. It would have
been best to report this to the Octave bug tracker, but I happened to
spot this thread and fix it anyway.

[1] https://bitbucket.org/mtmiller/octave-signal/commits/180d2f01ef5a
[2] https://bitbucket.org/mtmiller/octave-signal/raw/default/inst/resample.m

-- 
mike


reply via email to

[Prev in Thread] Current Thread [Next in Thread]