help-octave
[Top][All Lists]
Advanced

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

Re: decimate producing NaN


From: Mike Miller
Subject: Re: decimate producing NaN
Date: Tue, 27 Jan 2015 22:59:07 -0500
User-agent: Mutt/1.5.23 (2014-03-12)

Hi Ingo,

On Tue, Jan 27, 2015 at 06:54:49 -0800, inor0627 wrote:
> Hello,
> 
> I was trying to reduce a large dataset for plotting with external program.
> When using decimate from the signal package for this purpose, the ouput
> vector contains unexpected NaN. Additionally the number of NaN seems to be
> some kind of random. MWE:
> 
> >> sum(isnan(decimate(1:125000,184)))
> ans =  680
> >> sum(isnan(decimate(1:125000,185)))
> ans =  397
> >> sum(isnan(decimate(1:125000,186)))
> ans =  673
> 
> As the code above works as expected in Matlab 2012a, I wonder if I misused
> decimate or if the observed behaviour is a bug that I should report
> somewhere.
> I'm using signal 1.3.0 with octave 3.8.2 MXE on a win 7 machine.

I don't have access to test in Matlab, but reading their documentation
at [1] suggests that trying to call decimate with an argument of 184 is
a bad idea:

  Note: For better results when r is greater than 13, divide r into
  smaller factors and call decimate several times.

And indeed, decimating twice gives a better answer in Octave:

  >> x = 1:125000;
  >> y = decimate (x, 184);
  >> all (isnan (y))
  ans =  1
  >> factor (184)
  ans =
      2    2    2   23
  >> y = decimate (decimate (x, 8), 23);
  >> any (isnan (y))
  ans = 0

Anyway, it sounds like you got a better solution for what you are trying
to do with the plotdecimate function.

[1] http://www.mathworks.com/help/signal/ref/decimate.html

-- 
mike



reply via email to

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