strjoin — Join text elements using delimiters with MATLAB-compatible strjoin row-wise behavior.
strjoin combines text elements using a delimiter and returns joined text outputs. It supports MATLAB-compatible row-wise joining forms across supported string and character container inputs.
Syntax
out = strjoin(text, delimiter)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
text | Any | Yes | — | Input text array. |
delimiter | Any | Yes | — | Delimiter inserted between row elements. |
Returns
| Name | Type | Description |
|---|---|---|
out | Any | Joined string array. |
How strjoin works
strjoin(str, delim)requires an explicit delimiter argument in the current implementation.- String arrays are joined row-wise across columns, producing one output string per row.
- Character arrays are first interpreted row-by-row and then joined the same way.
- The return type is always a string array.
- Empty inputs with zero rows or zero columns currently return an empty
0x0string array. - Cell arrays of character vectors are not currently accepted by this implementation.
Does RunMat run strjoin on the GPU?
strjoin performs no provider dispatch. GPU-resident text inputs are gathered before the join is computed on the CPU.
GPU memory and residency
No. strjoin gathers text to host memory and returns a host-side string array.
Examples
Join a row vector of strings with commas
labels = ["alpha" "beta" "gamma"];
out = strjoin(labels, ", ")Expected output:
out = "alpha, beta, gamma"Join each row of a string matrix independently
names = ["Ada" "Lovelace"; "Grace" "Hopper"];
out = strjoin(names, " ")Expected output:
out = 2×1 string
"Ada Lovelace"
"Grace Hopper"Join rows of a character array
chars = ['ab'; 'cd'];
out = strjoin(chars, "-")Expected output:
out = 2×1 string
"a-b"
"c-d"Using strjoin with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how strjoin changes the result.
Run a small strjoin example, explain the result, then change one input and compare the output.
FAQ
Is the delimiter optional?⌄
Not in the current RunMat implementation. Pass strjoin(str, delim) explicitly.
Does strjoin join by row or by column?⌄
It joins across columns within each row, returning one output string per input row.
Can I pass a cell array of character vectors?⌄
Not currently. This implementation accepts string scalars, string arrays, and character arrays.
Related Strings functions
Transform
erase · eraseBetween · extractBetween · join · lower · pad · replace · split · strcat · strip · strrep · strsplit · strtrim · upper
Core
char · compose · num2str · sprintf · str2double · strcmp · strcmpi · string · string.empty · strings · strlength · strncmp
Search
contains · endsWith · startsWith · strfind
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how strjoin is executed, line by line, in Rust.
- View the source for strjoin 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.