data-types

Programming

SimLab supports these data types: double — Numbers and numeric arrays/matrices (default type) char — Strings enclosed in single quotes complex — Complex numbers (use i or j suffix, or complex(re, im)) logical — Boolean values (true/false, or 1/0) cell — Cell arrays that hold mixed types: {1, 'hello', [1 2]} struct — Structures with named fields: struct('name', value) symbolic — Symbolic math variables (declare with syms) tf/ss/zpk — Control system objects (transfer function, state-space, zero-pole-gain) Use class(x) to check the type of any value.

Syntax

42, 3.14, 1e-6          % numbers (double)
[1, 2; 3, 4]             % matrix
'hello'                  % string (char array)
3 + 4i, complex(3, 4)   % complex number
{1, 'a', [1 2]}         % cell array
struct('x', 1, 'y', 2)  % struct
syms x                  % symbolic variable

Examples

x = 42
▶ Run
A = [1 2 3; 4 5 6]
▶ Run
'hello world'
▶ Run
z = 3 + 4i
▶ Run
c = {1, 'text', [1, 2, 3]}
▶ Run
s = struct('name', 'SimLab', 'version', 2)
▶ Run
syms x y
▶ Run

See Also

Try SimLab — Free MATLAB® Alternative

466 functions. Runs in your browser. No install.

Open SimLab

Stay Updated

Get notified about new simulations and tools. We send 1-2 emails per month.