qammod — Map integer or bit symbols to QAM constellation points in MATLAB and RunMat.
qammod(X, M) maps integer symbols or bit groups X to complex QAM constellation points for modulation order M. Gray, binary, and custom symbol-ordering behavior follow MATLAB semantics.
Syntax
qammod(X, M)How qammod works
Xmust contain finite integer values in the inclusive range[0, M-1].InputType='bit'groups rows ofXinlog2(M)chunks per column/channel and maps each bit group to one symbol.Mmust be a power-of-two integer greater than one.- Square QAM orders such as 4, 16, 64, and 256 use symmetric odd integer amplitudes with minimum distance two.
- Non-square power-of-two orders use a rectangular grid with the larger dimension on the in-phase axis.
- The default
'gray'order applies Gray coding independently to the in-phase and quadrature grid indexes. 'UnitAveragePower', truescales the complete constellation so its average power is one.'OutputDataType', 'single'rounds the real and imaginary samples through single precision before returning the complex tensor or resident complex gpuArray output.'PlotConstellation', trueis not implemented yet.
Does RunMat run qammod on the GPU?
RunMat represents complex GPU tensors as interleaved real/imaginary buffers with complex storage metadata, so downstream GPU-aware FFT and signal paths can consume the modulation output without a host result.
The provider hooks receive a validated constellation table and write the complex output on device. They read back only a compact validation state for MATLAB-compatible symbol or bit errors.
GPU memory and residency
The builtin declares NewHandle residency for gpuArray inputs. Integer-symbol and bit-input gpuArrays stay resident through provider-side constellation modulation when provider support is available.
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]Binary symbol ordering
y = qammod(0:4, 16, 'bin')Expected output:
y = [-3+3i -3+1i -3-1i -3-3i -1+3i]Unit-average-power 16-QAM
y = qammod(0:15, 16, 'UnitAveragePower', true);
mean(abs(y).^2)Expected output:
ans = 1Bit input for 16-QAM
bits = [0 1; 0 1; 0 1; 0 1];
y = qammod(bits, 16, 'InputType', 'bit')Expected output:
y = [-3+3i 1-1i]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?⌄
Yes when the active provider implements the modulation hooks. It maps resident integer-symbol and bit-input gpuArrays directly to complex-interleaved gpuArray outputs.
Is bit input supported?⌄
Yes. InputType='bit' accepts numeric 0/1 or logical inputs and groups rows in log2(M) chunks for each column/channel.
Related Comms functions
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. 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 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.