RunMat
GitHub

ss — Create continuous-time state-space model objects from A, B, C, and D matrices.

ss(A, B, C, D) creates a state-space model object from numeric system matrices. It follows MATLAB-compatible matrix-shape validation for state, input, output, and direct-feedthrough terms.

Syntax

sys = ss(A, B, C, D)
sys = ss(A, B, C, D, Ts)
sys = ss(A, B, C, D, "Ts", Ts)
sys = ss(A, B, C, D, name, value, ...)

Inputs

NameTypeRequiredDefaultDescription
ANumericArrayYesState matrix with shape n-by-n.
BNumericArrayYesInput matrix with shape n-by-nu.
CNumericArrayYesOutput matrix with shape ny-by-n.
DNumericArrayYesFeedthrough matrix with shape ny-by-nu.
TsNumericScalarNo0.0Sample time (0 for continuous-time model).
nameStringScalarVariadicOption name ('Ts' or 'SampleTime').
valueAnyVariadicOption value.

Returns

NameTypeDescription
sysAnyState-space model object.

Errors

IdentifierWhenMessage
RunMat:ss:InvalidArgumentArguments do not match supported ss invocation forms.ss: invalid argument
RunMat:ss:InvalidOptionA name/value option token is unsupported or malformed.ss: invalid option
RunMat:ss:InvalidSampleTimeSample time is not a finite non-negative scalar.ss: sample time must be a finite non-negative scalar

How ss works

  • Returns an object whose class name is ss.
  • Stores A, B, C, D, Ts, InputDelay, OutputDelay, StateName, InputName, and OutputName properties.
  • Preserves the input matrix orientations on the returned object.
  • Uses continuous-time defaults with Ts equal to 0.
  • ss(A, B, C, D, Ts) stores a finite non-negative sample time.
  • ss(A, B, C, D, 'Ts', Ts) and ss(A, B, C, D, 'SampleTime', Ts) store a finite non-negative sample time.
  • Numeric scalar inputs are treated as 1-by-1 matrices and are accepted only when the resulting dimensions are consistent.
  • Complex, sparse, descriptor-form, uncertain, identified, and generalized models are not supported in this initial implementation.

GPU memory and residency

ss is a host-side object constructor. gpuArray matrix inputs are gathered before object construction, and the returned state-space object does not live on the GPU.

Examples

Creating a continuous-time state-space model

A = [0 1; -2 -3];
B = [0; 1];
C = [1 0];
D = 0;
G = ss(A, B, C, D);
class(G)

Expected output:

ans = "ss"

Reading stored state-space matrices

G = ss([0 1; -2 -3], [0; 1], [1 0], 0);
fprintf("%.0f %.0f %.0f %.0f %.0f %.0f\n", G.A(1), G.A(2), G.A(3), G.A(4), G.B(1), G.B(2));

Expected output:

0 -2 1 -3 0 1

Creating a discrete-time model

G = ss(0.5, 1, 1, 0, 0.1);
fprintf("%.1f\n", G.Ts);

Expected output:

0.1

Specifying sample time with a name-value pair

G = ss(0.5, 1, 1, 0, 'SampleTime', 0.2);
fprintf("%.1f\n", G.Ts);

Expected output:

0.2

How RunMat validates ss

ss validates finite real matrix inputs, state-space dimension consistency, supported name-value options, and sample-time constraints before constructing the host-side object. Unit and integration tests cover continuous and discrete constructors, property access, invalid dimensions, invalid sample times, descriptor signatures, and gpuArray gathering.

See Correctness & Trust for the full methodology and coverage table.

Using ss with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how ss changes the result.

Run a small ss example, explain the result, then change one input and compare the output.

FAQ

Does ss simulate step or impulse responses?

No. This builtin constructs a state-space object. Response functions can add ss parsing separately.

Does ss accept complex or sparse matrices?

Not yet. Inputs must be finite real numeric scalars or dense matrices.

How are dimensions validated?

A must be n-by-n, B must be n-by-nu, C must be ny-by-n, and D must be ny-by-nu.

Will ss(gpuArray(A), B, C, D) return a gpuArray-backed object?

No. ss gathers gpuArray inputs and stores host tensors on the returned object.

db · impulse · nyquist · step · tf

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how ss is executed, line by line, in Rust.

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.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.