sym — Create a scalar symbolic variable or constant.
sym creates scalar symbolic variables from identifier text and scalar symbolic constants from numeric input. Nonconstant symbolic values remain symbolic through supported arithmetic, trigonometric, and limit operations.
Syntax
S = sym(value)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
value | Any | Yes | — | Variable name, numeric scalar, or existing symbolic scalar. |
options | Any | Variadic | — | Reserved symbolic options. |
Returns
| Name | Type | Description |
|---|---|---|
S | Any | Scalar symbolic variable or constant. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:sym:ArgCount | Options beyond the scalar input are supplied. | sym: unsupported options |
RunMat:sym:InvalidText | Text input is neither a valid identifier nor a numeric scalar literal. | sym: invalid symbolic text |
RunMat:sym:InvalidInput | Input cannot be represented as a scalar symbolic value. | sym: expected a scalar text, numeric, logical, or symbolic input |
How sym works
- Text that is a valid MATLAB identifier creates a symbolic variable with that name.
- Finite numeric, integer, logical, and scalar numeric tensor inputs create scalar symbolic constants with class
sym. - Text containing a finite numeric scalar creates that numeric symbolic constant.
- Symbolic values are host-only and do not participate in GPU fusion or residency.
Examples
Create a symbolic variable
x = sym('x')Create a symbolic numeric constant
a = sym(2)Using sym with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how sym changes the result.
Run a small sym example, explain the result, then change one input and compare the output.
FAQ
Does sym create symbolic arrays?⌄
No. RunMat currently represents scalar symbolic expressions; array-valued symbolic containers are not materialized.
Related Math functions
Elementwise
abs · angle · complex · conj · double · exp · expm1 · factorial · gamma · heaviside · hypot · imag · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · sign · single · sqrt · times
Trigonometry
acos · acosh · asin · asinh · atan · atan2 · atanh · cos · cosd · cosh · deg2rad · rad2deg · sin · sind · sinh · tan · tand · tanh
Reduction
all · any · cummax · cummin · cumprod · cumsum · cumtrapz · diff · gradient · max · mean · median · min · nnz · prod · std · sum · trapz · var
Structure
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how sym is executed, line by line, in Rust.
- View the source for sym 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.