1
$\begingroup$

I have a list of numbers data of length 10^7. I have values

rate = 100000.;
cutoff = 2000.;

I try to low pass filter with

LowpassFilter[data
, Quantity[cutoff, "Hz"]
, SampleRate -> Quantity[rate, "Hz"]]

I get the error message:

LowpassFilter::srate: The value of sample rate should be a positive machine-sized integer number or a Quantity representing frequency instead of $Failed.

But if I replace rate with its value, it works fine.

LowpassFilter[data, Quantity[cutoff, "Hz"], 
 SampleRate -> Quantity[100000., "Hz"]]

Why is that, and is there a workaround?

$\endgroup$
5
  • $\begingroup$ The help file says the rate needs to be an integer. Your rate 100000. is a real number. Use an integer 100000 $\endgroup$ – bill s Jun 21 at 19:47
  • 1
    $\begingroup$ Your first version works for me on Mathematica 12.3. Are you on an earlier version? $\endgroup$ – mikado Jun 21 at 20:40
  • $\begingroup$ What help file is that? The error message says "The value of sample rate should be a positive machine-sized integer number or a Quantity representing frequency" Mine is the latter. Note also that LowpassFilter does not complain when you use a real number in the quantity. See my second example. $\endgroup$ – abwatson Jun 21 at 20:42
  • $\begingroup$ I am on 12.3 for Mac OS. $\endgroup$ – abwatson Jun 21 at 20:43
  • $\begingroup$ The first version works for me on 12.2 on Windows 10. $\endgroup$ – Derek H Jul 23 at 13:35
0
$\begingroup$

No answer to why, but found a work-around. Round the rate value.

LowpassFilter[data, Quantity[cutoff, "Hz"], 
 SampleRate -> Quantity[Round[rate], "Hz"]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.