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.5Inspect a Butterworth low-pass response
[b, a] = butter(2, 0.25, 'low');
[H, w] = freqz(b, a, 8);
fprintf('%d %.4f %.4f\n', length(H), abs(H(1)), w(end));Expected output:
8 1.0000 2.7489Using 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 · cheb2ord · conv · conv2 · deconv · downsample · envelope · filter · filtfilt · fir1 · gauspuls · hamming · hann · hilbert · periodogram · pulstran · pwelch · rectpuls · resample · sawtooth · sinc · spectrogram · square · tripuls · unwrap · upsample · zplane
Elementwise
abs · angle · bsxfun · complex · conj · double · erf · erfcinv · exp · expm1 · factorial · flintmax · gamma · gammaln · heaviside · hypot · idivide · imag · intmax · intmin · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · realmax · realmin · realsqrt · rescale · sign · single · sqrt · swapbytes · times · uint32
Trigonometry
acos · acosh · asin · asinh · atan · atan2 · atanh · cos · cosd · cosh · cospi · deg2rad · pol2cart · rad2deg · sin · sind · sinh · sinpi · tan · tand · tanh
Reduction
all · any · bounds · cummax · cummin · cumprod · cumsum · cumtrapz · diff · gradient · max · maxk · mean · median · min · mink · movmax · movmean · movmedian · movmin · movprod · movstd · movsum · movvar · nnz · prod · rms · std · sum · trapz · var
Structure
bandwidth · isdiag · ishermitian · issymmetric · istril · istriu · symrcm
Optim
coneprog · fminbnd · fminunc · fsolve · fzero · integral · linprog · lsqcurvefit · lsqnonlin · optimset · quad · secondordercone
Ops
cross · ctranspose · dot · mldivide · mpower · mrdivide · mtimes · pagemtimes · pagetranspose · trace · transpose
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.