Generated reference › Symbolic Expression — Control Systems/Symbolic
kind: generated#block#control-systems-symbolic

Symbolic Expression — Control Systems/Symbolic

f(x) x^2*y+sin

Control_Systems/Symbolic/Symbolic_Expression · 1 input / 1 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Description#

The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.

Symbolic Expression

Control Systems / Symbolic

Evaluates an expression you type, y = f(x₁, …, xn), on the input at every sample. The expression is written in MATLAB syntax over the names in Variables, which name the entries of the input vector in order, and it may be a scalar or a matrix – [f1; f2; f3] gives a column of three. It is read once, when the configuration loads, by the console's own symbolic engine (the reader behind str2sym), so what runs per sample is plain arithmetic: this is MATLAB's matlabFunction(str2sym(...)) on a wire.

Ports

  • x – the variables, a vector of n entries (a column [n,1] or a row [1,n]) where n is the number of names in Variables: entry k is the k-th name. A Mux in front builds it from scalar signals.
  • y – the expression's value, shaped like the expression: [1,1] for a scalar, [r,c] for an r-by-c matrix literal. The shape follows from the configuration alone.

Parameters

  • Expression – the expression, in MATLAB syntax: numbers, the declared variables, pi, + - * / ^ (and their elementwise spellings .* ./ .^, which mean the same on scalars), parentheses, and the functions sin cos tan sec csc cot asin acos atan acot sinh cosh tanh asinh acosh atanh exp log log2 log10 sqrt abs sign heaviside. A matrix is written [a, b; c, d]: commas separate the entries of a row and semicolons separate rows – a space does not separate entries here. Anything else is refused with a reason naming it: an unknown name, a function outside the set (atan2, min, floor and gamma among them), the imaginary unit, a relation, and dirac: the impulse is a distribution with no value at a sample, so no signal carries it. heaviside is 1/2 at 0, as MATLAB's is. e is refused too, because MATLAB's str2sym reads it as a variable and the console's engine as Euler's number; write exp(1).
  • Variables – the names of the input's entries, in order, separated by spaces or commas: x y z. Each is a MATLAB identifier, none may repeat, and none may be a function name or pi, e, i, j, Inf, NaN or eps. At most 12.
  • Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.

Code export

All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text. Each entry is emitted as one inline expression with its constants folded to 17 significant digits; nothing is exposed as a tunable parameter, because the expression is the structure. Where a target lacks a function it gets the identity: Java has no inverse hyperbolic functions and PLC Structured Text no hyperbolic functions at all, so those are written through log, exp and sqrt. The three HDL targets are simulation-only real arithmetic (IEEE math_real, and the Verilog real math system functions), quantized to Q16.16 only at the ports: a sine, a logarithm or a division of signals is not a fixed-point datapath, so the HDL body is not offered as synthesizable.

Simulink bridge

None (Support::None). Evaluating a symbolic expression is a Symbolic Math Toolbox operation, and that toolbox ships no Simulink library, so there is no block to cross to; the bridge reports this block rather than dropping it, and it has no parity testbench. No configuration of it crosses, including "Sampling Time (s)".

Notes

  • Algebraic, with no state: the output depends only on the current input.
  • The engine's form is what runs. The engine keeps numbers exact (1e-3*x is x/1000 to it) and prints its own canonical form (x*x*x is x^3); constants are folded to doubles only after it. A rational too large for 64 bits is refused by the engine with its own reason.
  • The domain is yours to respect. The expression is evaluated as written, in real arithmetic: log of a negative number, sqrt of a negative number or a division by zero gives NaN or Inf in the simulator and in the exported code alike (MATLAB's own target would go complex instead).
  • Size limits are on the generated code: 144 entries, 4000 operations per entry. The calculus blocks of this family – Symbolic Derivative, Gradient, Jacobian, Hessian, Divergence and Curl, Laplacian and Taylor Approximation – take the same two parameters and the same input.
  • No state space: the map is nonlinear in general, so model reduction correctly declines the block.

Code facts#

FactValue
registered typeControl_Systems/Symbolic/Symbolic_Expression
familyControl_Systems/Symbolic
solver environment classICoreBlock_0_Control_Systems_1_Symbolic_2_Symbolic_Expression
sourcesrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Symbolic/Symbolic_Expression/ICoreBlock_0_Control_Systems_1_Symbolic_2_Symbolic_Expression.cpp
headersrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Symbolic/Symbolic_Expression/ICoreBlock_0_Control_Systems_1_Symbolic_2_Symbolic_Expression.h
default size on canvas130 × 70 px
ports at insert1 in, 1 out
code generators implementedPython, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Ports#

#DirectionSignal typeDescription label
1inICoreDoublex
2outICoreDoubley

Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.

Configuration variables#

Config variableDefaultSimulink parameter
Expressionx^2*y + sin(x)—
Variablesx y—

Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.

supportSupport::None
Simulink path—
port-count rulePortsParam::None
SampleTime parameteryes

Caveat (shown to the user): evaluating a symbolic expression is a Symbolic Math Toolbox operation (str2sym, matlabFunction), and that toolbox ships no Simulink library at all, so there is no library path a diagram could name; the block is reported rather than dropped when a model crosses

Catalog contract: src/ICoreBlocks/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h

Description vs code#

The checker has a blind spot here — it could not resolve something (a grouped port bullet, a computed config name), which is reported and never counted as a pass. A reader has to settle it:

  • B0 every stimulus in the sample errored — cross-checks skipped

The verdict above is tools/docs/check_block_descriptions.py (P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.

File banner (developer view)#

The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).

Symbolic Expression -- an expression compiled at config load, evaluated per sample y = f(x_1, ..., x_n)

"Variables" names the entries of the input vector in order; "Expression" is MATLAB-syntax text over them -- a scalar, or a matrix literal whose entries are separated by commas and whose rows by semicolons. The text is read by the family's reader, handed to the console's symbolic engine (the reader behind str2sym), and the engine's canonical answer is folded into a numeric tree that compute_h() and all ten generators walk. Everything but this block's identity -- its ports, configs, description, icon and Simulink entry -- is ICoreSymbolicBlockBase's; read ICoreSymbolicExpressionSupport.h for the pipeline and the function set.

VERIFIED OUTSIDE ICORE, because code-export verification compares this block with itself. The block's own C++ evaluation of its rig expression -- six entries that between them use every function of the set -- was compared with MATLAB R2026a evaluating the same text through matlabFunction(str2sym(...)): max |difference| 8.88e-16 over the six entries, which is rounding on the last bit rather than a tolerance.

Sample results#

No stimulus produced a sampled output in this rig — Invalid input size at Symbolic Expression block: ICore Blocks/Home/Symbolic Expression. That is a fact about the single-block rig, not a verdict on the block: an offline batch fit, a block whose output only appears at onSolverFinish, or one that needs a driven environment cannot be exercised alone.

Category unsampled · sample time 0.1 · 60 steps · commit 83b4036dc8d5efdf28a47c36be1e27203065c75b · produced by docsSample --out <folder> --blocks Symbolic_Expression Symbolic_Derivative Gradient Jacobian Hessian Divergence_And_Curl Laplacian Taylor_Approximation Linear_Program LTI_System Wind_Turbulence_Model --steps 60

Sample data: docs/generated/samples/Control_Systems__Symbolic__Symbolic_Expression.json