Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the length of the frequency response adjustable #562

Open
hyperkomplexe opened this issue Aug 11, 2024 · 1 comment
Open

Make the length of the frequency response adjustable #562

hyperkomplexe opened this issue Aug 11, 2024 · 1 comment

Comments

@hyperkomplexe
Copy link

When calling H, w = freqresp(filter) the returned frequency axis w is fixed at 257 rows.

This is an issue when someone (like me for example) needs a higher resolution along the frequency axis.

Matlab has an optional argument n which is used to specify the length of the axis required.
https://ch.mathworks.com/help/signal/ref/freqz.html

Scipy also has worN as an optional argument allowing this to be specified.
https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.freqz.html

I would suggest adding something similar.

I suppose it should be simple enough to implement, just add the length as an optional argument to the freqresp call.

"""
H, w = freqresp(filter)
Frequency response `H` of a `filter` at (normalized) frequencies `w` in
radians/sample for a digital filter or radians/second for an analog filter
chosen as a reasonable default.
"""

Then pass it also into the _freqrange call.

_freqrange(::FilterCoefficients{:z}) = range(0, stop=π, length=257)

Cheers

@martinholters
Copy link
Member

One issue here is that we have freqresp(filter::FilterCoefficients, w), where w can be anything that can be broadcast over, including single numbers. So freqresp(filter, 2) already has a meaning -- evaluating the filter at ω=2. Maybe adding a kwarg to the one-argument method of freqresp (that gets then passed on to _freqrange) might be an option, so that one could do e.g. freqresp(filter; n=1000).

(Meanwhile, the work-around would be calling freqresp(filter, range(0, stop=π, length=1000) for z-domain filters.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants