一个简单的卷积码编码程序
以下是一个简单的卷积码编码程序的MATLAB实现。
【一个简单的卷积码编码程序】
% *****************************************
% **
% *This function implements the*
% *state machine for a convolutional*
% *code with rate 1/2 and K = 3.*
% *****************************************function output = conv_code(mssg)input = zeros(1,length(mssg) + 3);
input(1:length(mssg)) = mssg;
% padding message with 0 in the front
output = zeros(1,2*(length(mssg) + 2));
% output of covolutional code
k = 1;
state = 0;
% initial state
i = 1;
while i <= length(mssg) + 3
switch(state)
case 0% state 0
if(input(i) == 0)
state = 0;
% next state 0
y = [0 0];
else
state = 2;
% next state 2
y = [1 1];
end
case 1% state 1
if(input(i) == 0)
state = 0;
% next state 0
y = [1 1];
else
state = 2;
% next state 2
y = [0 0];
end
case 2% state 2
if(input(i) == 0)
state = 1;
% next state 1
y = [1 0];
else
state = 3;
% next state 3
y = [0 1];
end
case 3% state 3
if(input(i) == 0)
state = 1;
% next state 1
y = [0 1];
else
state = 3;
% next state 3
y = [1 0];
end
end
if(i ~= length(mssg) + 3)
output(k) = y(1);
output(k + 1) = y(2);
end
k = k + 2;
i = i + 1;
end
end
推荐阅读
- 热闹中的孤独
- JAVA(抽象类与接口的区别&重载与重写&内存泄漏)
- 放屁有这三个特征的,请注意啦!这说明你的身体毒素太多
- 一个人的旅行,三亚
- 布丽吉特,人生绝对的赢家
- 慢慢的美丽
- 尽力
- 一个小故事,我的思考。
- 家乡的那条小河
- 《真与假的困惑》???|《真与假的困惑》??? ——致良知是一种伟大的力量