📄 qpskspacetimemain.m
字号:
clear all; clc;
% Number of state; change here:
% Use 4, 8, 16, 32, 64, 128, or 256
nrState = 4;
% Signal to Noise Ratio in dB
SNRindB = [8 10 12 14 16];
% Number of frame
N = 10000;
% Number of data per frame
D = 130;
% The state generator matrices
% Number of state is limited to 256
switch nrState
case {4}
G = [2 1 0 0;0 0 2 1];
case {8}
G = [2 2 1 0 0;2 0 0 2 1];
case {16}
G = [0 2 2 1 0 0;2 0 0 2 2 1];
case {32}
G = [2 3 2 2 1 0 0;2 3 1 0 0 2 1];
case {64}
G = [2 2 3 2 1 2 0 0;1 2 2 3 0 0 1 2];
case {128}
G = [2 2 1 2 3 1 2 0 0;1 2 3 2 1 0 0 2 1];
case {256}
G = [2 3 2 1 3 1 1 2 0 0;1 3 2 1 2 2 0 0 2 1];
otherwise
disp ('Number of state must be 4, 8, 16, 32, 64, 128, 256!');
break;
end
% Form the trellis and the binary map for decoding
[st1 st2 bin] = stTrellis(G);
% Generate simple flat fading channel
ch = rand(2, N) + j*rand(2, N);
for i = 1:length(SNRindB),
fprintf('SNR = %d\n', SNRindB(i));
numOfErr = 0; ber = 0;
for j = 1:N
% Calling the main function, replace the function here if needed
[err, rat] = sttc4PskUseMex(st1, st2, bin, nrState, G, D, ch(:, j), SNRindB(i));
ber = ber + rat;
if err == 1
numOfErr = numOfErr + 1;
end
end
% Bit error rate
berTot(i) = ber/N;
% Frame error rate
fer(i) = numOfErr/N;
end;
% Plot here...
semilogy(SNRindB, fer, '-o');
grid on;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -