n = 2^m- 1; % define code length k = n-m; % information bit length
msg = randint(k*4, 1,2); % of the signals are randomly extracted, and the uniformly distributed arbitrary integer matrix (2,2, 1) stems (MSG) are generated.
Title ("Encoder input signal")
P = cyclic poly (n, k)% cyclic code generator polynomial, n=7, k = 4code = encode (msg, n, k,' cyclic', p); % coding function, which encodes the signal incorrectly. Subplots (2, 2, 2) stem (code).
Title ("Encoder Output Signal")
Decode = decode (code, n, k,' cyclic', p)% decodes the signal, decodes the received codeword, and recovers it.
In order to generate the original information, the decoding parameters and methods must be exactly the same as those used in coding.
Subplot (2, 2, 3) stems (recoding)
Title ('decoder output signal') t =-1:0.01:1;
X = recoding; % assign recode to x, and set the length and fft to n = length (x); FX = FFT(x); df = 100/N; N = 0:N/2; f = n * df
Subplots (2, 2, 4);
plot(f,ABS(FX(N+ 1))* 2/N); Grid; Title ("spectrogram")
2. The relation scheme between bit error rate and signal-to-noise ratio (tested by (3,2) cyclic code) m = 2;;
n = 2^m- 1; % define code length k = n-m; % information bit length Fs = 40% system sampling frequency FD =1; % code rate n = fs/FD;
m = 2; % decimal number
For snrpbit =1:100; % SNR SNR = SNRpBit/log2(M);
% manufacturing 100 information groups, each group has k-bit MSG = Randint (100, k, [0,1]);
Code = encode(msg, n, k,' cyclic/binary'); % add noise
% Add Gaussian white noise to the modulated signal
Noisycode=awgn(code, SNR-10 * log10 (0.5)-10 * log10 (n),' actually measured', [],' db'); % converts floating-point numbers into binary, and the waveform shaping process is I = 1: 100 and a = 1: k+ 1.
if noisycode(i,a)& lt; 0.5 noisycode(i,a)= 0; other
noisycode(i,a)= 1; end
End end% decoding
newmsg = decode(noisycode,n,k,' cyclic '); % calculated bit error rate
[number, ratio ]=biterr(newmsg, msg); SNRpBit)= ratio;
Disp([' error rate is', num2str (ratio)]); end
BER performance of cyclic codes through additive white Gaussian noise channel at% different SNR (1);
Title ('Error Rate of Cyclic Codes under Different SNR') Legend ('Error Rate',' *') xlabel ('SNR');
Ylabel ("bit error rate under additive Gaussian white noise");