1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【MATLAB】通信の勉強をする前の練習問題【問題編⑤グラフの出力】

Posted at

#【第5章】BERグラフを出力する
信号検出性能を見るためにはBERを縦軸に、SNR[dB]を横軸にとったグラフを出力することが多いということをいつか述べました。
次の諸元でシミュレーションを行った時のBERグラフを出力しましょう。
・変調方式:QPSK
・通信路:AWGN
・送信bit数:$10^6$bit
・送受信アンテナ数:2本
・SNR:0[dB]~12[dB]
そろそろMATLABについて調べるのも慣れてきたころかと思いますので、グラフ出力の方法などは調べながらノーヒントでやってみましょう。
また、今回だけはfor文を使います。

#解答

% おまじない
clear all

N = 10^6;
SNRdB = 0:12;
BER = zeros(1,length(SNRdB));

for count = 1:length(SNRdB)

    % 雑音の生成
    SNR = 10^(SNRdB(count)/10);
    No = 1/SNR;
    noise_comp = sqrt(No/2) * randn(2,N/2) + 1j*sqrt(No/2) * randn(2,N/2);

    % 送信bit生成 ~ QPSK変調
    TX_bit = randi([0,1],2,N);
    TX_BPSK = zeros(size(TX_bit));
    TX_BPSK(TX_bit == 0) = -1;
    TX_BPSK(TX_bit == 1) = 1;
    TX_QPSK = (TX_BPSK(:,1:2:end) + 1j*TX_BPSK(:,2:2:end))/sqrt(2);

    %受信
    RX_QPSK = TX_QPSK + noise_comp;

    % QPSK復調
    RX_BPSK1 = zeros(2,N/2);
    RX_BPSK1(real(RX_QPSK) > 0) = 1;
    RX_BPSK1(real(RX_QPSK) < 0) = -1;
    
    RX_BPSK2 = zeros(2,N/2);
    RX_BPSK2(imag(RX_QPSK) > 0) = 1;
    RX_BPSK2(imag(RX_QPSK) < 0) = -1;
    
    RX_BPSK = zeros(size(TX_bit));
    RX_BPSK(:,1:2:end) = RX_BPSK1;
    RX_BPSK(:,2:2:end) = RX_BPSK2;
    
    % BPSK復調
    RX_bit = zeros(size(TX_bit));
    RX_bit(RX_BPSK == -1) = 0;
    RX_bit(RX_BPSK == 1) = 1;

    %BERの計算
    BER(count) = sum(abs(TX_bit(:) - RX_bit(:)))/(2*N);
end

figure
semilogy(SNRdB,BER);
grid on
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?