false — Create logical arrays filled with false values.
false creates logical arrays filled with false values. MATLAB-compatible mode accepts scalar dimensions, multiple scalar dimensions, a row size vector, and 'like'. Integer dimensions are read exactly, negative dimensions become zero, and trailing singleton dimensions are normalized according to MATLAB array-shape rules.
Syntax
L = false()
L = false(n)
L = false(size_vector)
L = false(m, n, ...)
L = false(prototype)
L = false(..., "logical")
L = false(..., "like", prototype)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
n | SizeArg | Yes | — | Square size. |
size_vector | SizeArg | Yes | — | Size vector defining output dimensions. |
dims | SizeArg | Variadic | — | Dimension sizes. |
prototype | LikePrototype | Yes | — | Prototype value when no numeric dimension arguments are provided. |
typename | StringScalar | No | "logical" | Class override keyword (logical). |
like_kw | StringScalar | Yes | "like" | Like keyword. |
prototype | LikePrototype | Yes | — | Prototype array used for class/device. |
Returns
| Name | Type | Description |
|---|---|---|
L | LogicalArray | Logical output array. |
Errors
| Identifier | When | Message |
|---|---|---|
| — | The 'like' keyword is provided without a prototype argument. | false: expected prototype after 'like' |
| — | The 'like' keyword is provided multiple times. | false: multiple 'like' specifications are not supported |
| — | A trailing option string is not supported. | false: unrecognised option |
| — | Dimension arguments fail numeric/shape parsing. | false: dimension arguments must be numeric and nonnegative |
How false works
false()returns the scalar logicalfalse.false(n)returns an n x n logical array of false values.false(m, n, ...)returns a logical array with the requested dimensions.false(sz)accepts one row size vector. A column vector or multiple vector size inputs are rejected.- All eight integer classes are exact size controls. Negative signed dimensions become zero; noninteger, nonfinite, or platform-unrepresentable dimensions reject before allocation.
false(___, 'like', prototype)preserves applicable sparsity or owning-provider residency while the result remains logical. The prototype never supplies output shape, sofalse('like', prototype)is 1 × 1.false(A), the'logical'class option, single-precision size controls, and resident size controls are independently gated RunMat extensions rather than MATLAB-compatible syntax. An admitted resident size control is gathered structurally and still produces host logical output unless residency is requested explicitly with'like'.
Examples
Creating a 2x3 logical array of false values
mask = false(2, 3)Expected output:
mask = [0 0 0; 0 0 0]Creating a logical array from a size vector
dims = [1 4 2];
mask = false(dims)Expected output:
mask =
1x4x2 logical array
0 0 0 0
0 0 0 0Creating a false mask with the same size and residency as an existing array
A = rand(2, 2);
mask = false(size(A), 'like', A)Expected output:
mask =
2x2 logical array
0 0
0 0Using false with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how false changes the result.
Run a small false example, explain the result, then change one input and compare the output.
FAQ
What does false() return?⌄
It returns the logical scalar false.
Does false(n) create a square array?⌄
Yes. false(n) returns an n x n logical array of false values, matching MATLAB behavior.
How does false(sz) interpret a size vector?⌄
A row vector is treated as the full set of dimensions, so false([2 3 4]) yields a 2x3x4 logical array. Column vectors and multiple vector inputs are rejected.
Does false keep results on the GPU?⌄
Yes, when residency is requested explicitly with 'like'. RunMat constructs the logical result through the prototype handle's owning provider; a GPU value supplied as an ordinary size control does not implicitly determine shape and residency at once.
Is the 'logical' option required?⌄
No. false always returns logical values. RunMat retains the redundant 'logical' spelling only in extension mode.
Related Array functions
Creation
colon · createArray · empty · eye · full · inf · linspace · logspace · magic · meshgrid · nan · nchoosek · ndgrid · nonzeros · ones · peaks · perms · rand · randi · randn · randperm · range · sparse · spdiags · speye · spones · sprand · true · zeros
Grouping
accumarray · combinations · discretize · findgroups · groupcounts · grp2idx · splitapply
Sorting Sets
argsort · intersect · ismember · ismembertol · issorted · issortedrows · setdiff · setxor · sort · sortrows · union · unique
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how false is executed, line by line, in Rust.
- View the source for false 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.