RunMat
GitHub

upper — Convert strings, character arrays, and cell arrays of character vectors to uppercase.

upper(text) converts every alphabetic character in text to uppercase. It accepts string scalars, string arrays, character arrays, and cell arrays of character vectors, mirroring MATLAB behaviour. Non-alphabetic characters are returned unchanged.

How upper works in RunMat

  • String inputs stay as strings. String arrays preserve their size, orientation, and missing values.
  • Character arrays are processed row by row. The result remains a rectangular char array; if any row grows after uppercasing (for example 'ß' → "SS"), the array widens and shorter rows are padded with spaces.
  • Cell arrays must contain string scalars or character vectors. The result is a cell array of the same size with each element converted to uppercase; other types raise MATLAB-compatible errors.
  • Missing string scalars (string(missing)) remain <missing> so downstream code behaves like MATLAB.
  • Inputs that are numeric, logical, structs, or GPU tensors raise MATLAB-compatible type errors.

How upper runs on the GPU

upper executes on the CPU. Text values currently reside in host memory, so providers do not offer device kernels for this builtin. When you pass a container that still holds GPU handles (for example, a struct whose string fields were gathered lazily), RunMat gathers those handles before performing the conversion. If you store characters as numeric code points on the GPU, gather and convert them to text before calling upper.

GPU memory and residency

RunMat keeps text data in host memory, so you typically work with ordinary string and character arrays. When text originates from GPU computations (for example, numeric code points produced by kernels), gather those values to the host and convert them to text before calling upper.

Examples

Convert a string scalar to uppercase

txt = "RunMat";
result = upper(txt)

Expected output:

result = "RUNMAT"

Uppercase each element of a string array

labels = ["north" "South"; "East" "west"];
uppered = upper(labels)

Expected output:

uppered = 2×2 string
    "NORTH"    "SOUTH"
    "EAST"     "WEST"

Uppercase character array rows while preserving shape

animals = char("cat", "doge");
result = upper(animals)

Expected output:

result =

  2×4 char array

    'CAT '
    'DOGE'

Uppercase a cell array of character vectors

C = {'hello', 'World'};
out = upper(C)

Expected output:

out = 1×2 cell array
    {'HELLO'}    {'WORLD'}

Keep missing strings as missing

vals = ["data", string(missing), "gpu"];
converted = upper(vals)

Expected output:

converted = 1×3 string
    "DATA"    <missing>    "GPU"

Handle text stored on a GPU input

codes = gpuArray(uint16('runmat'));
txt = char(gather(codes));
result = upper(txt)

Expected output:

result = 'RUNMAT'

FAQ

Does upper change non-alphabetic characters?

No. Digits, punctuation, whitespace, and symbols remain untouched. Only alphabetic code points that have distinct uppercase forms are converted.

What happens to character array dimensions?

RunMat uppercases each row independently and pads with spaces when an uppercase mapping increases the row length. This mirrors MATLAB’s behaviour so the result always has rectangular dimensions.

Can I pass numeric arrays to upper?

No. Passing numeric, logical, or struct inputs raises a MATLAB-compatible error. Convert the data to a string or character array first (for example with string or char).

How are missing strings handled?

Missing string scalars remain <missing> and are returned unchanged. This matches MATLAB’s handling of missing values in text processing functions.

Will upper ever execute on the GPU?

Not today. The builtin gathers GPU-resident data automatically and performs the conversion on the CPU so the results match MATLAB exactly. Providers may add device-side kernels in the future, but behaviour will remain compatible.

These functions work well alongside upper. Each page has runnable examples you can try in the browser.

lower, string, char, regexprep, strcmpi, erase, eraseBetween, extractBetween, join, pad, replace, split, strcat, strip, strrep, strtrim

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how upper works, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code — faster, on any GPU, with no license required.

  • Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
  • Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
  • A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.

Getting started · Benchmarks · Pricing

Try RunMat — free, no sign-up

Start running MATLAB code immediately in your browser.