nyquist — Compute or plot the Nyquist frequency response of a SISO transfer function.
nyquist(sys) plots a supported scalar SISO tf model when outputs are discarded. Output forms return real, imaginary and frequency columns for the default or explicit frequency grid. Continuous models are evaluated at s = jω; discrete models use z = exp(jωTs). State-space, FRD, model arrays and MIMO inputs are not yet supported.
Syntax
nyquist(sys)
nyquist(sys,w)
re = nyquist(sys,w)
[re,im] = nyquist(sys,w)
[re,im,wout] = nyquist(sys,w)
[re,im,wout] = nyquist(sys)
re = nyquist(sys)Inputs
sys- Type
Any- Required
- Yes
- Description
- Scalar SISO tf model.
w- Type
NumericArray- Required
- No
- Description
- Finite nonnegative angular frequencies.
Returns
re- Type
NumericArray- Description
- Real response column.
im- Type
NumericArray- Description
- Imaginary response column.
wout- Type
NumericArray- Description
- Frequency column.
Returned values from nyquist depend on how many outputs the caller requests.
Errors
RunMat:nyquist:InvalidArgument- When
- Invocation form, frequency input or output count is invalid.
- Message
nyquist: invalid argument
RunMat:nyquist:InvalidModel- When
- Required model properties are malformed.
- Message
nyquist: invalid model
RunMat:nyquist:UnsupportedModel- When
- The model is well formed but outside supported SISO tf behavior.
- Message
nyquist: unsupported model
Frequency grid and outputs
An explicit w must be a nonempty vector of finite nonnegative angular frequencies. With no w, a continuous model uses a deterministic logarithmic grid based on poles and zeros; a discrete model uses 200 points inside zero and the Nyquist frequency π/Ts, excluding potentially singular endpoints. These grid choices describe RunMat behavior, not verified MATLAB point-for-point parity.
re, im and wout are same-length double N-by-1 columns. One output returns re, two return re and im, and three add wout. A no-output call plots the positive-frequency curve and, for exactly real coefficients, mirrors the negative-frequency curve. Complex-coefficient models are evaluated without a mirrored curve. An exact denominator zero at a requested frequency produces an explicit singularity error.
Compatibility and placement
Native typed-integer frequency/model metadata, logical numeric roles, and GPU-resident consumed values are conservative RunMat-only extensions. Typed integers must be exactly representable in binary64 before complex frequency evaluation. Delayed transfer functions are not supported; nonzero input or output delay is rejected exactly rather than suppressed by a tolerance.
Frequency evaluation and output materialization run on the host. Valid consumed resident coefficient or frequency values gather through their owning provider only after host-known form, compatibility and structural checks; unrelated model properties are not read. The numeric output path has no UI effect; plotting needs the UI service. Calls may suspend and throw, but have no workspace, filesystem, network, callback, randomness or time effect.
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.0Response of a sampled transfer function
H = tf(1, [1 -.5], .1); [re, im, w] = nyquist(H, [0 1]); fprintf("%.1f %.1f\n", re(1), im(1));Expected output:
2.0 0.0Plot a Nyquist diagram
H = tf(1, [1 2 1]); nyquist(H); fprintf("ok\n");Expected output:
okUsing 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 accept MIMO or state-space models?⌄
Not yet. The current implementation accepts scalar SISO tf objects.
Does nyquist run on a GPU?⌄
No. The calculation is host-side; admitted consumed resident input values gather through their owner.
Related Control functions
Source you can read
Every RunMat function's source is public. 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 a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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.