Why do I receive "Error using RectangularQAMModulator"

27 次查看(过去 30 天)
% Set the OFDM and QAM parameters
N = 64; % Number of subcarriers
M = 16; % Size of QAM constellation
CP = 16; % Cyclic prefix length
% Set the number of nodes in the network
numNodes = 4;
% Set the frame length and number of slots
frameLength = 1000;
numSlots = numNodes;
% Create an OFDM modulator object
ofdmMod = comm.OFDMModulator('FFTLength', N, 'NumGuardBandCarriers', [0;0], 'CyclicPrefixLength', CP);
% Create an OFDM demodulator object
ofdmDemod = comm.OFDMDemodulator('FFTLength', N, 'NumGuardBandCarriers', [0;0], 'CyclicPrefixLength', CP);
% Create a QAM modulator object
qamMod = comm.RectangularQAMModulator('ModulationOrder', M, 'NormalizationMethod', 'Average power');
Warning: COMM.RECTANGULARQAMMODULATOR will be removed in a future release. Use QAMMOD instead. See this release note for more information.
% Create a QAM demodulator object
qamDemod = comm.RectangularQAMDemodulator('ModulationOrder', M, 'NormalizationMethod', 'Average power');
Warning: COMM.RECTANGULARQAMDEMODULATOR will be removed in a future release. Use QAMDEMOD instead. See this release note for more information.
% Generate a random data sequence for each node
data = randi([0 M-1], frameLength, numNodes);
% Modulate the data using QAM
modData = qamMod(data);
Error using RectangularQAMModulator
The input must be a column vector.
% Modulate the QAM symbols using OFDM
txSignal = ofdmMod(modData);
% Perform DCT on the OFDM symbols
txSignal = dct(txSignal);
% Create a TDMA schedule
schedule = repmat((1:numNodes)', 1, frameLength/numSlots);
schedule = schedule(:);
% Transmit the data using TDMA
txSignal = txSignal(:,schedule);
% Add channel noise to the transmitted signal
rxSignal = awgn(txSignal, 10);
% Perform IDCT on the received signal
rxSignal = idct(rxSignal);
% Demodulate the received signal using OFDM
rxModData = ofdmDemod(rxSignal);

回答(1 个)

Abhinav Aravindan
Abhinav Aravindan 2024-12-3,7:10
编辑:Abhinav Aravindan 2024-12-3,7:53
The “comm.RectangularQAMModulator” appears to accept only scalar or column vectors as input signals according to the documentation below.
However, the input data is in the form of a matrix in the above program resulting in the error. To resolve this, you may try providing the data as individual column vector inputs and then combining the results as per your requirement.
However, I would recommend you to use the “qammod” function as “comm.RectangularQAMModulator” has been removed from MATLAB R2024b and has been replaced with “qammod” which supports the Input signal as a scalar, vector, matrix or array.
You may refer to the documentation below for more information:

类别

Help CenterFile Exchange 中查找有关 Modulation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by