?? rsc_encode.m
字號:
function y = rsc_encode(g, x)
% encodes a block of data x (0/1)with a recursive systematic
% convolutional code with generator vectors in g, and
% returns the output in y (0/1).
% if terminated>0, the trellis is perfectly terminated
% if terminated<0, it is left unterminated;
% determine the constraint length (K), memory (m), and rate (1/n)
% and number of information bits.
[n,K] = size(g);
m = K - 1;
L_info = length(x);
L_total = L_info + m;
% initialize the state vector
state = zeros(1,m);
% generate the codeword
for i = 1:L_total
if le(i,L_info)
d_k = x(i);
else
% terminate the trellis
d_k = rem( g(1,2:K)*state', 2 );
end
a_k = rem( g(1,:)*[d_k state]', 2 );
[output_bits, state] = encode_bit(g, a_k, state);
% since systematic, first output is input bit
output_bits(1,1) = d_k;
y(n*(i-1)+1:n*i) = output_bits;
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -