freqz — Evaluate digital filter frequency response.
freqz(b, a, n) evaluates the complex frequency response of a digital filter at n points between 0 and Nyquist. With fs, returned frequencies are in Hz instead of radians/sample.
Syntax
H = freqz(b, a)
H = freqz(b, a, n)
H = freqz(b, a, n, fs)
[H, w] = freqz(b, a)
[H, w] = freqz(b, a, n)
[H, w] = freqz(b, a, n, fs)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
b | Any | Yes | — | Numerator coefficient vector. |
a | Any | Yes | — | Denominator coefficient vector. |
n | NumericScalar | No | 512 | Number of response samples. |
fs | NumericScalar | No | — | Sampling frequency for output frequencies in Hz. |
Returns
| Name | Type | Description |
|---|---|---|
H | NumericArray | Complex frequency response. |
w | NumericArray | Frequencies in radians/sample or Hz when fs is supplied. |
Returned values from freqz depend on how many outputs the caller requests.
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:freqz:ArgCount | The argument count is outside supported forms. | freqz: expected freqz(b, a, [n, [fs]]) |
RunMat:freqz:InvalidCoefficients | Coefficient inputs are empty or not numeric vectors. | freqz: invalid coefficient input |
RunMat:freqz:InvalidN | The response length is not a positive integer scalar. | freqz: n must be a positive integer |
RunMat:freqz:InvalidFs | The sampling frequency is not a positive finite scalar. | freqz: fs must be a positive finite scalar |
RunMat:freqz:Internal | Response tensor construction fails internally. | freqz: internal error |
How freqz works
- Default response length is 512 samples.
[H, w] = freqz(...)returns complex responseHand frequency vectorwas column vectors.- Without
fs,wis in radians/sample over[0, pi). - With
fs,wis in Hz over[0, fs/2).
Does RunMat run freqz on the GPU?
Host-side analysis only.
GPU coefficient inputs are gathered before evaluation.
Examples
Evaluate a simple FIR response
[H, w] = freqz([1 1], 1, 4);
fprintf('%.1f %.1f %.4f\n', real(H(1)), imag(H(3)), w(3));Expected output:
2.0 -1.0 1.5708Evaluate a response in Hz
b = fir1(20, 0.25);
[H, f] = freqz(b, 1, 8, 1000);
fprintf('%.1f %.1f\n', f(1), f(end));Expected output:
0.0 437.5Using freqz with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how freqz changes the result.
Run a small freqz example, explain the result, then change one input and compare the output.
FAQ
Does freqz include the Nyquist point?⌄
The supported numeric n form samples n points over [0, pi), matching the common one-sided response grid used by MATLAB's freqz(b,a,n) form.
Can freqz analyze IIR filters?⌄
Yes. Pass numerator b and denominator a; freqz evaluates the transfer function directly on the unit circle.
Related Math functions
Signal
blackman · butter · buttord · conv · conv2 · deconv · downsample · envelope · filter · filtfilt · fir1 · gauspuls · hamming · hann · hilbert · periodogram · pulstran · pwelch · rectpuls · sawtooth · sinc · spectrogram · square · tripuls · unwrap · upsample · zplane
Elementwise
abs · angle · complex · conj · double · exp · expm1 · factorial · gamma · heaviside · hypot · imag · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · sign · single · sqrt · times
Trigonometry
acos · acosh · asin · asinh · atan · atan2 · atanh · cos · cosd · cosh · deg2rad · rad2deg · sin · sind · sinh · tan · tand · tanh
Reduction
all · any · cummax · cummin · cumprod · cumsum · cumtrapz · diff · gradient · max · mean · median · min · nnz · prod · std · sum · trapz · var
Structure
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how freqz is executed, line by line, in Rust.
- View the source for freqz in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.