qammod — Map integer symbols or grouped bits to rectangular QAM points.
qammod(X,M) maps whole-valued symbols or grouped bits to complex QAM points. Gray and binary orders, a custom symbol permutation, unit-average-power scaling, and output class can be selected.
Syntax
Y = qammod(X, M)
Y = qammod(X, M, symorder, Name, Value)Inputs
X- Type
NumericArray- Required
- Yes
- Description
- Integer symbols or grouped bit input.
M- Type
NumericScalar- Required
- Yes
- Description
- Power-of-two modulation order greater than one.
args- Type
Any- Required
- Variadic
- Description
- Optional symbol order and name-value options.
Returns
Y- Type
NumericArray- Description
- Complex rectangular-QAM baseband samples.
Errors
- When
- Symbols, modulation order, mapping, or options are invalid.
- Message
qammod: invalid argument
Constellation and controls
X must contain finite whole symbols from 0 through M-1. M must be a power of two greater than one. Square orders use symmetric odd in-phase and quadrature amplitudes; non-square powers of two use a rectangular grid with the longer in-phase axis.
Gray order is the default and applies to each grid axis. 'bin' uses binary order; a custom permutation labels constellation points. InputType='bit' groups rows in log2(M) chunks per channel, first bit most significant. Logical inputs, including scalars, require bit input. UnitAveragePower=true scales the constellation to average unit power.
PlotConstellation=true is recognized but explicitly unsupported. The output precision defaults to single only when X has single storage, otherwise double; OutputDataType selects 'single' or 'double'.
Execution and residency
Supported resident symbol and bit arrays use the owning acceleration provider's modulation hooks and produce complex-interleaved resident output. Unsupported hooks use host validation and protected re-upload; malformed provider output is rejected. Modulation terminates fusion.
This pure operation has no callback, workspace, filesystem, network, randomness, or time effects. Explicit GPU input keeps device intent through the supported hook or the fallback upload.
Examples
Default 16-QAM Gray mapping
y = qammod(0:15,16);Expected output:
y = [-3+3i -3+1i -3-3i -3-1i -1+3i -1+1i -1-3i -1-1i 3+3i 3+1i 3-3i 3-1i 1+3i 1+1i 1-3i 1-1i]Use binary order
y = qammod(0:4,16,'bin');Expected output:
The first points begin -3+3i, -3+1i, -3-1i, -3-3i.Normalize average constellation power
y = qammod(0:15,16,'UnitAveragePower',true); p = mean(abs(y).^2);Expected output:
p = 1Group bit rows into QAM symbols
bits = [0 1;0 1;0 1;0 1]; y = qammod(bits,16,'InputType','bit');Expected output:
y = [-3+3i 1-1i]Preserve single input precision
y = qammod(single(0:3),4);Using qammod with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how qammod changes the result.
Run a small qammod example, explain the result, then change one input and compare the output.
FAQ
Does qammod execute on the GPU?⌄
When the owning provider has modulation hooks, resident symbol and bit inputs produce resident complex output. Unsupported hooks can use host validation and re-upload.
Is bit input supported?⌄
Yes. InputType='bit' accepts numeric zero/one or logical arrays and groups log2(M) rows per symbol for each channel.
Related Comms functions
Source you can read
Every RunMat function's source is public. Read exactly how qammod is executed, line by line, in Rust.
- View the source for qammod in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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.