Add new signal generator method that only creates the PRBS

This commit is contained in:
2026-04-21 14:20:48 +02:00
parent 20b23dc37e
commit 0ef8129a2c
5 changed files with 975 additions and 5 deletions

View File

@@ -0,0 +1,40 @@
% Minimal example: Signalgenerator -> PAMmapper -> demap -> BER
clear; clc;
repoRoot = fileparts(fileparts(fileparts(mfilename("fullpath"))));
addpath(genpath(repoRoot));
orders = [2 4 6 8];
userOrder = 7;
fprintf("PAM | bits checked | errors | BER\n");
fprintf("----+--------------+--------+-----\n");
for M = orders
if M == 6
bitsPerBlock = 5;
else
bitsPerBlock = log2(M);
end
bitSignal = Signalgenerator( ...
"form", signalform.prms, ...
"dimension", bitsPerBlock, ...
"order", userOrder).process();
if M == 6
txBits = reshape(bitSignal.signal.', [], 1);
txBits = txBits(1:end - mod(numel(txBits), bitsPerBlock));
else
txBits = bitSignal.signal;
end
mapper = PAMmapper(M, 0);
txSymbols = mapper.map(txBits);
rxBits = mapper.demap(txSymbols);
[checkedBits, errors, ber] = calc_ber(rxBits, txBits);
fprintf("%3d | %12d | %6d | %.1e\n", M, checkedBits, errors, ber);
end