RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact
  • License
  • Privacy

Learn

  • Docs
  • Blog
  • Benchmarks
  • RunMat vs MATLAB Online

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

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
    • clc
    • diary
    • disp
    • display
    • format
    • input

input — Prompt users for interactive input in MATLAB and RunMat.

input(prompt) displays prompt, reads one line from the user, and returns the evaluated value. Passing 's' as the second argument returns raw text instead of numeric evaluation, following MATLAB semantics.

Syntax

value = input()
value = input(prompt)
value = input(prompt, stringFlag)
value = input(stringFlag, prompt)

Inputs

NameTypeRequiredDefaultDescription
promptAnyYes—Prompt text shown to the user.
stringFlagStringScalarYes—Set to 's' to return the raw input text.

Returns

NameTypeDescription
valueAnyParsed scalar/matrix value, or raw text when using string mode.

Errors

IdentifierWhenMessage
RunMat:input:TooManyInputsMore than two input arguments are passed to input.input: too many inputs
RunMat:input:InvalidStringFlagThe string mode flag is not a scalar string/char 's'.input: invalid string flag
RunMat:input:PromptMustBeRowVectorPrompt char array is not 1-by-N.input: prompt must be a row vector
RunMat:input:PromptMustBeScalarStringPrompt string array is not scalar.input: prompt must be a scalar string
RunMat:input:InvalidPromptTypePrompt is not a string scalar or row char vector.input: invalid prompt type
RunMat:input:InteractionFailedInteractive prompt callback fails.input: interaction failed
RunMat:input:EvalFailedExpression evaluation hook rejects the input expression.input: invalid expression
RunMat:input:InvalidNumericExpressionNumeric fallback parser rejects the input expression.input: invalid numeric expression

How input works

  • Prompts accept character row vectors and string scalars. When omitted, RunMat uses "Input: ".
  • The function always blocks until the host supplies a line of text (via the REPL, CLI pipe, or wasm bindings). In wasm hosts, prompts are delivered to the installed async input handler and execution continues after the handler resolves. If the host cannot provide input, RunMat raises RunMat:input:InteractionFailed instead of returning a synthetic value.
  • When 's' (or "s") is provided, the return value is a character array containing exactly what the user typed (without the trailing newline).
  • Without 's', RunMat forwards the response through the same numeric parser that backs str2double. This covers scalar numbers, MATLAB-style vector/matrix literals, Inf, NaN, and complex tokens. Arbitrary expressions (for example 1+rand()) are not evaluated automatically—read the text with 's' and pass it to eval once that builtin lands.
  • Empty responses (just pressing Enter) return an empty [] double, consistent with MATLAB.
  • When the numeric parser rejects the text, RunMat raises RunMat:input:InvalidNumericExpression so callers can present a friendly retry loop.

Example

value = input("Enter a scalar: ")

Using input with coding agents

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

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

FAQ

Does RunMat evaluate arbitrary MATLAB expressions?⌄

Not yet. The numeric branch reuses the str2double parser, which supports MATLAB numeric literals (scalars, vectors, matrices, Inf, NaN, complex pairs) but does not run arbitrary code. When you need to evaluate expressions such as 1+sin(pi/4), capture the text via input(..., 's') and pass it to eval in a follow-up release.

What happens if the user just presses Enter?⌄

RunMat returns the empty double [], matching MATLAB’s input behaviour.

Can I call input inside GPU workloads?⌄

Yes. Prompts always flow through the host console/UI. GPU-resident prompt arguments are gathered once before display, and the response itself is always a host value.

What does input do in MATLAB?⌄

input(prompt) displays the prompt string and waits for the user to type a response. The response is evaluated as a MATLAB expression. Use input(prompt, 's') to return the raw text as a string without evaluation.

How do I get string input from the user in MATLAB?⌄

Use str = input('Enter text: ', 's'). The 's' flag tells MATLAB to return the typed text as a character vector instead of evaluating it as an expression.

What is the difference between input and keyboard in MATLAB?⌄

input pauses for a single value from the user and returns it, while keyboard drops into an interactive debugging session. RunMat supports input for scripted user interaction.

Can I validate user input in MATLAB?⌄

Use a while loop: keep calling input until the value passes your validation check. For example, while x < 0; x = input('Enter positive number: '); end.

Does input work in RunMat's browser sandbox?⌄

Yes, when the host installs an async input handler. If a browser or sandbox host cannot provide interactive input, RunMat raises RunMat:input:InteractionFailed deterministically.

Related Io functions

Net

accept · read · readline · tcpclient · tcpserver · write

Repl Fs

addpath · cd · copyfile · delete · dir · exist · fileattrib · fileparts · fullfile · genpath · getenv · getpref · isenv · isfile · isfolder · ispref · ls · matlabroot · memmapfile · mkdir · movefile · open · opentoline · path · pathsep · pcode · pwd · readstruct · rehash · restoredefaultpath · rmdir · rmpath · run · savepath · setenv · setpref · system · tempdir · tempname · uigetdir · uigetfile · uiputfile · unsetenv · userpath · what · winqueryreg · xmlread · xmlwrite

Tabular

arrayDatastore · csvread · csvwrite · detectImportOptions · dlmread · dlmwrite · fileDatastore · parquetDatastore · parquetinfo · parquetread · readcell · readmatrix · readtable · readtimetable · spreadsheetImportOptions · writecell · writematrix · writetable · writetimetable · xlsread · xlswrite

Audio

audioinfo · audioread

Io

clc · diary · disp · display · format

Filetext

fclose · feof · fgetl · fgets · fileread · filewrite · fopen · fprintf · fread · frewind · fwrite · readlines · writelines

Archive

gunzip · gzip · unzip

Hdf5

h5disp · h5info · h5read · h5write · h5writeatt · hdf5info · hdf5read · hdf5write

Import

importdata · textscan

Json

jsondecode · jsonencode

Mat

load · matfile · save

Http

sendmail · urldecode · urlencode · weboptions · webread · websave · webwrite

Open-source implementation

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

  • View the source for input 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.

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
  • How input works
  • Example
  • Using input with coding agents
  • FAQ
  • Related Io functions
  • Net
  • Repl Fs
  • Tabular
  • Audio
  • Io
  • Filetext
  • Archive
  • Hdf5
  • Import
  • Json
  • Mat
  • Http
  • Open-source implementation
  • About RunMat