nyquist — Compute or plot Nyquist frequency responses of SISO transfer-function models.
nyquist(sys) plots Nyquist responses for supported SISO tf models, and output forms return real, imaginary, and frequency vectors. It follows MATLAB-compatible call signatures for default or explicit frequency grids.
Syntax
nyquist(sys)
nyquist(sys, w)
re = nyquist(sys, w)
[re, im] = nyquist(sys, w)
[re, im, wout] = nyquist(sys)
[re, im, wout] = nyquist(sys, w)sysmust currently be a SISOtfobject.wmust be a real vector of finite non-negative frequencies.re,im, andwoutare returned asN x 1column vectors.
How nyquist works
- Supports SISO
tfobjects created bytf(num, den)ortf(num, den, Ts). - Continuous-time models are evaluated as
H(j*w). - Discrete-time models are evaluated on the unit circle as
H(exp(j*w*Ts)). - When
wis omitted, continuous-time models use a deterministic logarithmic frequency grid based on transfer-function poles and zeros. - When
wis omitted, discrete-time models use a deterministic grid from zero to the Nyquist frequencypi/Ts. [re, im] = nyquist(sys, w)returns real and imaginary response column vectors.[re, im, wout] = nyquist(sys, w)returns three same-length column vectors.- No-output calls plot the positive-frequency curve and mirror the negative-frequency curve for real-coefficient systems.
- Input/output delays and non-
tfmodel classes raise clear diagnostics in this implementation.
GPU memory and residency
nyquist returns host-resident response vectors. It does not preserve gpuArray residency.
Examples
Compute response data at explicit frequencies
H = tf(1, [1 1]);
w = [0 1 2];
[re, im, wout] = nyquist(H, w);
fprintf("%.1f %.1f %.1f %.1f\n", re(1), re(2), im(2), wout(3));Expected output:
1.0 0.5 -0.5 2.0Plot a Nyquist diagram
H = tf(1, [1 2 1]);
nyquist(H);
fprintf("ok\n");Expected output:
okDiscrete-time frequency response
H = tf(1, [1 -0.5], 0.1);
[re, im] = nyquist(H, 0:0.5:5);
fprintf("%.1f %.1f\n", re(1), im(1));Expected output:
2.0 0.0How RunMat validates nyquist
nyquist validates object class, coefficient type and shape, delay properties, sample time, denominator singularities, and frequency-vector inputs before evaluating the transfer-function response. Tests cover continuous and discrete responses, multi-output shapes, plotting smoke, complex coefficients, VM dispatch, and representative diagnostics.
- Implementation: `crates/runmat-runtime/src/builtins/control/nyquist.rs`
See Correctness & Trust for the full methodology and coverage table.
Using nyquist with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how nyquist changes the result.
Run a small nyquist example, explain the result, then change one input and compare the output.
FAQ
Does nyquist support MIMO systems?⌄
Not yet. The current implementation supports SISO transfer-function objects.
Does nyquist support state-space models?⌄
Not yet. ss, zpk, frd, model arrays, and identified-system families are outside this first implementation.
Does nyquist run on the GPU?⌄
The frequency-response calculation runs on the host from model metadata. The builtin is registered with GPU/fusion metadata as a residency sink so GPU-backed coefficient inputs are gathered predictably before evaluation.
Related Control functions
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how nyquist is executed, line by line, in Rust.
- View the source for nyquist 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.