MATLAB中的随机整数

时间:2013-05-17 15:25:05

标签: string algorithm matlab matrix

我需要生成一个带有随机数字信息的输入信号,该信号由0到15的40320个整数组成,使用矩形16QAM调制方案,最少101个错误,以确定误码率。

如何在Matlab中实现这一点?到目前为止我已经编写了这段代码。有人可以开导我吗?

 M=16; %signal constellation size
 log2M =log2(M); %number of bits per symbol
 N= 40320; %No of random integers sent
 coderate =1;% FEC not required
 MinNoErr =101; %Minimum no of received symbol error 
 MaxNoErr =11e9; %Maximum no of received symbol error 
 nsamp =1; %No of samples per symbol
 B= randi([1, M-1],N,1); % Random integer data stream

% Modulate
hMod = comm.RectangularQAMModulator(M); % Create a 16-QAM modulator
txqam = modulate(modem.qammod(M),B);% Modulate using 16-QAM.
txqam =T; %transmited signal

% Send signal over an AWGN channel
EbNo = [5:1:15]; % In dB
SNR = EbNo + 10*log10(log2M*coderate) - 10*log10(nsamp);
hChan = comm.AWGNChannel('NoiseMethod', 'Signal to noise ratio (SNR)', ...
'SNR',SNR);

hChan.SignalPower = (T' * T)/ length(T);
ynoisy = step(hChan,T);

1 个答案:

答案 0 :(得分:1)

根据我的理解,你需要的是一个长度为40320的向量,其间隔为[1,15]的随机整数。如果是这样,您只需要:

my_vector = randi(15 + 1, [1, 40320]) - 1;

如果这不是你想要的,请说明你需要什么。