colorcube — Return the colorcube colormap as an m-by-3 RGB array.

colorcube returns a colorcube palette as an m-by-3 numeric RGB array with values in [0, 1]. With no argument, it uses the current colormap length, or 256 when no figure colormap length is active.

Syntax

c = colorcube()
c = colorcube(m)

Inputs

NameTypeRequiredDefaultDescription
mNumericScalarNocurrent colormap length or 256Number of colors as a nonnegative integer.

Returns

NameTypeDescription
cNumericArraym-by-3 RGB colormap array with values in [0, 1].

Errors

IdentifierWhenMessage
RunMat:colormapArray:InvalidArgumentThe requested colormap length or RGB colormap array is invalid.colormap array: invalid argument

How colorcube works

  • colorcube() returns an m-by-3 RGB matrix.
  • colorcube(m) returns exactly m rows, where m must be a nonnegative integer.
  • The result can be passed directly to colormap.

Examples

Apply a colorcube colormap

surf(peaks(40));
colormap(colorcube(64));
colorbar;

Generate a colorcube matrix

c = colorcube(32);

Using colorcube with coding agents

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

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

FAQ

What size is colorcube()?

It returns the active colormap length when one exists, otherwise 256 rows by 3 columns.

Open-source implementation

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

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.