impulse — Compute or plot impulse responses in MATLAB and RunMat.
impulse(sys) computes the impulse response of supported dynamic system models. With output arguments it returns numeric response data; without outputs it plots the response, consistent with MATLAB semantics.
Syntax
y = impulse(sys)
y = impulse(sys, tFinal)
y = impulse(sys, t)
[y,t] = impulse(sys)
[y,t] = impulse(sys, tFinal)
[y,t] = impulse(sys, t)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
sys | Any | Yes | — | SISO tf model. |
time | Any | No | — | Final time scalar or explicit time vector. |
Returns
| Name | Type | Description |
|---|---|---|
y | NumericArray | Impulse response samples (column vector). |
t | NumericArray | Time samples (column vector). |
Returned values from impulse depend on how many outputs the caller requests.
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:impulse:InvalidArgument | Inputs do not match supported impulse invocation forms. | impulse: invalid argument |
RunMat:impulse:InvalidModel | Input system is not a supported tf object with valid required metadata. | impulse: invalid model |
RunMat:impulse:InvalidTime | Time argument is invalid for the model class or sampling mode. | impulse: invalid time input |
RunMat:impulse:UnsupportedModel | Model is well-formed but unsupported by the current impulse implementation. | impulse: unsupported model |
RunMat:impulse:DiscreteLimit | Discrete simulation would exceed platform or configured sample limits. | impulse: discrete simulation limit exceeded |
RunMat:impulse:Internal | Internal response assembly failed. | impulse: internal error |
How impulse works
- Supports real SISO
tfobjects created bytf(num, den)ortf(num, den, Ts). impulse(sys)uses a deterministic default time vector.impulse(sys, tFinal)generates a deterministic time vector from zero totFinal.impulse(sys, t)respects an explicit real, finite, non-negative, strictly increasing time vector.[y, t] = impulse(...)returnsyandtasN x 1column vectors for supported SISO systems.- Continuous-time responses are evaluated from a controllable canonical state-space realization.
- Discrete-time responses respect MATLAB's unit-area impulse convention: the input pulse has height
1/Ts, and time vectors must use integer multiples ofTs. - Unsupported model classes, delays, complex coefficients, static gains, and non-strictly-proper transfer functions raise clear diagnostics.
GPU memory and residency
impulse returns host-resident response vectors. It does not preserve gpuArray residency.
Examples
Compute a first-order impulse response
H = tf(20, [1 5]);
t = 0:0.1:1;
[y, tout] = impulse(H, t);Expected output:
y and tout are column vectors.Plot an impulse response
H = tf(1, [1 3 2]);
impulse(H);Discrete-time impulse response
H = tf(1, [1 -0.5], 0.1);
[y, t] = impulse(H, 0:0.1:0.5);How RunMat validates impulse
impulse validates the model class, coefficient type and shape, delay properties, strict properness, sample time, and time vector before simulation. Tests cover SISO continuous response values, discrete response values, explicit time input, multi-output shapes, and representative diagnostics.
- Implementation: `crates/runmat-runtime/src/builtins/control/impulse.rs`
See Correctness & Trust for the full methodology and coverage table.
Using impulse with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how impulse changes the result.
Run a small impulse example, explain the result, then change one input and compare the output.
FAQ
Does impulse support MIMO systems?⌄
Not yet. The current implementation supports real SISO tf objects. Broader model-family and MIMO support is tracked separately.
Why are non-strictly-proper transfer functions rejected?⌄
Those systems include a direct impulse term that is not represented as a finite numeric response vector in the current runtime model.
Can I use state-space or zero-pole-gain models?⌄
Not yet. ss, zpk, frd, model arrays, and identified-system families are outside this first implementation.
Related Control functions
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how impulse is executed, line by line, in Rust.
- View the source for impulse 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.