?? rsc_encode.m
字號(hào):
function y = rsc_encode(g, x, end1)% Copyright Nov. 1998 Yufei Wu% MPRG lab, Virginia Tech.% for academic use only% 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 end1>0, the trellis is perfectly terminated% if end1<0, it is left unterminated;% determine the constraint length (K), memory (m), and rate (1/n)% and number of information bits.%***********************************************************************% rsc 編碼器% 輸入 % g 生成矩陣 % x 輸入序列% endl 尾比特處理標(biāo)志% >0 有 m 個(gè)尾比特 編碼至 x 最后一個(gè)比特到達(dá)最后一個(gè)寄存器% <0 沒(méi)有尾比特 x 最后一個(gè)比特進(jìn)入編碼器% 輸出% 編碼比特 (信息位 校驗(yàn)位1 校驗(yàn)位2 。。校驗(yàn)位n-1 信息位。。。。)%***********************************************************************[n,K] = size(g);m = K - 1;if end1>0 L_info = length(x); L_total = L_info + m;else L_total = length(x); L_info = L_total - m;end %根據(jù)endl來(lái)決定編碼輸出% >0 增加 m 個(gè)尾比特 m為編碼器寄存器的數(shù)目% <0 不加 尾比特% initialize the state vectorstate = zeros(1,m);% 將編碼器的寄存器初始化為全0% generate the codewordfor i = 1:L_total if end1<0 | (end1>0 & i<=L_info) % | 或 % & 與 d_k = x(1,i); % 正常編碼 elseif end1>0 & i>L_info % terminate the trellis d_k = rem( g(1,2:K)*state', 2 ); % 尾比特處理, end a_k = rem( g(1,:)*[d_k state]', 2 ); % a_k 是編碼器的第一個(gè)寄存器的輸入; [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; % 編碼比特 (信息位 校驗(yàn)位1 校驗(yàn)位2 。。校驗(yàn)位n-1 信息位。。。。)end
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -