RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
See all docs
Builtin Reference
    • blanks
    • char
    • compose
    • convertCharsToStrings
    • convertContainedStringsToChars
    • convertStringsToChars
    • genvarname
    • int2str
    • isletter
    • isspace
    • isStringScalar
    • isstrprop
    • mat2str
    • native2unicode
    • newline
    • num2str
    • sprintf
    • sscanf
    • str2double
    • str2num
    • strcmp
    • strcmpi
    • string
    • string.empty
    • strings
    • strlength
    • strncmp
    • strncmpi
    • strtok
    • unicode2native

char — Convert numeric codes and text values into character arrays in MATLAB and RunMat.

char converts inputs into a character array. Numeric inputs are interpreted as UTF-16 code units, and text inputs are padded as needed so output rows share width. Isolated surrogate code units are not yet representable by RunMat's character storage.

Syntax

C = char()
C = char(X)
C = char(X...)

Inputs

X
Type
Any
Required
Yes
Description
Input value to convert into character data.
X...
Type
Any
Required
Variadic
Description
Multiple inputs converted row-wise and padded.
NameTypeRequiredDefaultDescription
XAnyYes—Input value to convert into character data.
X...AnyVariadic—Multiple inputs converted row-wise and padded.

Returns

C
Type
Any
Description
Character array result.
NameTypeDescription
CAnyCharacter array result.

Errors

RunMat:char:InvalidInput
When
Input type cannot be converted to character data.
Message
char: invalid input
RunMat:char:InvalidCodePoint
When
Numeric input cannot be represented by RunMat's scalar-value character storage.
Message
char: numeric input cannot be represented as a RunMat character
RunMat:char:InvalidDimension
When
Array inputs are not 2-D (or trailing singleton dimensions).
Message
char: inputs must be 2-D
RunMat:char:InternalError
When
Internal character array construction failed.
Message
char: internal error
IdentifierWhenMessage
RunMat:char:InvalidInputInput type cannot be converted to character data.char: invalid input
RunMat:char:InvalidCodePointNumeric input cannot be represented by RunMat's scalar-value character storage.char: numeric input cannot be represented as a RunMat character
RunMat:char:InvalidDimensionArray inputs are not 2-D (or trailing singleton dimensions).char: inputs must be 2-D
RunMat:char:InternalErrorInternal character array construction failed.char: internal error

Behavior

char() with no arguments returns a 0×0 character array.

Real numeric values are truncated toward zero and clamped to the UTF-16 code-unit range 0 through 65535. All eight integer classes are read from exact native storage.

RunMat's character storage cannot yet represent isolated UTF-16 surrogate code units; those inputs produce an explicit error instead of silently changing the value.

Logical inputs and interactive resident numeric inputs are separately mode-gated RunMat extensions.

String scalars and character vectors become individual rows. Rows are padded on the right with spaces to match the longest row.

String arrays with one or two dimensions contribute one row per element using MATLAB's column-major ordering.

Cell arrays must contain character vectors or string scalars. Each element becomes exactly one row in the result.

Inputs may be mixed and are vertically concatenated in the order they appear.

Complex inputs are unsupported and raise MATLAB-compatible errors.

Execution and placement

Numeric conversion is bounded to UTF-16 code units. This remains partial compatibility because the current Unicode-scalar storage cannot encode isolated surrogate code units. The character result is host-resident; resident numeric inputs gather and can suspend.

Examples

Converting a string scalar to a character row

name = char("RunMat")

Expected output:

name =
    'RunMat'

Building a character matrix from multiple rows

rows = char("alpha", "beta")

Expected output:

rows =
    'alpha'
    'beta '

Transforming numeric codes to characters

codes = [77 65 84 76 65 66];
letters = char(codes)

Expected output:

letters =
    'MATLAB'

Padding a string array into a character matrix

animals = ["cat"; "giraffe"];
C = char(animals)

Expected output:

C =
    'cat    '
    'giraffe'

Creating rows from a cell array of character vectors

dirs = {'north', 'east', 'west'};
chart = char(dirs)

Expected output:

chart =
    'north'
    'east '
    'west '

Converting GPU-resident codes back to text

G = gpuArray([82 85 78 77 65 84]);
label = char(G)

Expected output:

label =
    'RUNMAT'

Using char with coding agents

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

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

FAQ

Does char accept numeric arrays with more than two dimensions?⌄

Trailing singleton dimensions are accepted as an equivalent two-dimensional shape. A non-singleton dimension beyond the second raises an error.

How are rows padded when lengths differ?⌄

Each row is right-padded with space characters so every row in the result has the same width as the longest row that was produced.

Can I convert cell arrays that contain empty text?⌄

Yes. Empty strings or character vectors become rows with zero columns; they still participate in padding when combined with longer rows.

What happens if a numeric value is not an integer?⌄

Finite real numeric values are truncated toward zero, then clamped to 0 through 65535. Isolated UTF-16 surrogate code units raise an error because RunMat's character storage represents Unicode scalar values.

Are code points above the Basic Multilingual Plane supported?⌄

No. Numeric codes are clamped to the UTF-16 code-unit range 0 through 65535. Isolated surrogate code units cannot be represented by RunMat's current character storage and raise an error.

Can char convert complex numbers?⌄

No. Complex values are not supported because MATLAB also rejects them. Convert the data to real values before calling char.

Does char keep characters on the GPU?⌄

No. Conversion returns a host character array; RunMat does not provide a GPU character-array representation.

Related Strings functions

Core

blanks · compose · convertCharsToStrings · convertContainedStringsToChars · convertStringsToChars · genvarname · int2str · isletter · isspace · isStringScalar · isstrprop · mat2str · native2unicode · newline · num2str · sprintf · sscanf · str2double · str2num · strcmp · strcmpi · string · string.empty · strings · strlength · strncmp · strncmpi · strtok · unicode2native

Text Analytics

addDependencyDetails · addEntityDetails · addLemmaDetails · addPartOfSpeechDetails · addSentenceDetails · addTypeDetails · bagOfNgrams · bagOfWords · cosineSimilarity · doc2sequence · encode · extractFileText · extractHTMLText · fastTextWordEmbedding · findElement · getAttribute · htmlTree · ind2word · isVocabularyWord · normalizeWords · readWordEmbedding · removeLongWords · removeShortWords · removeStopWords · removeWords · stopWords · tokenDetails · tokenizedDocument · trainWordEmbedding · vaderSentimentScores · vec2word · word2ind · word2vec · wordEncoding · writeWordEmbedding

Transform

append · deblank · erase · eraseBetween · erasePunctuation · eraseURLs · extractAfter · extractBefore · extractBetween · insertAfter · insertBefore · join · lower · pad · replace · replaceBetween · reverse · split · splitlines · strcat · strip · strjoin · strjust · strrep · strsplit · strtrim · upper

Search

contains · endsWith · matches · startsWith · strfind

Pattern

digitsPattern · lettersPattern · pattern · regexpPattern · textBoundary · wildcardPattern

Regex

regexp · regexpi · regexprep

Source you can read

Every RunMat function's source is public. Read exactly how char is executed, line by line, in Rust.

  • View the source for char in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • Behavior
  • Execution and placement
  • Examples
  • Converting a string scalar to a character row
  • Building a character matrix from multiple rows
  • Transforming numeric codes to characters
  • Padding a string array into a character matrix
  • Creating rows from a cell array of character vectors
  • Converting GPU-resident codes back to text
  • Using char with coding agents
  • FAQ
  • Related Strings functions
  • Core
  • Text Analytics
  • Transform
  • Search
  • Pattern
  • Regex
  • Source you can read
  • About RunMat