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
  • 1
    $\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
    Commented Jun 21, 2021 at 19:47
  • 1
    $\begingroup$ Your first version works for me on Mathematica 12.3. Are you on an earlier version? $\endgroup$
    – mikado
    Commented Jun 21, 2021 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
    Commented Jun 21, 2021 at 20:42
  • $\begingroup$ I am on 12.3 for Mac OS. $\endgroup$
    – abwatson
    Commented Jun 21, 2021 at 20:43
  • $\begingroup$ The first version works for me on 12.2 on Windows 10. $\endgroup$
    – Derek H
    Commented Jul 23, 2021 at 13:35

1 Answer 1

1
$\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 and acknowledge you have read our privacy policy.

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