Code covered by the BSD License  

Highlights from
MATLAB for Digital Communication

image thumbnail

MATLAB for Digital Communication


Won Yang (view profile)


The MATLAB programs in "MATLAB/Simulink for Digital Communication" authored by Won Y. Yang et. al

function [output,state]=conv_encoder(G,K,input,state,termmode)
% generates the output sequence of a binary convolutional encoder
% G    : N x LK Generator matrix of a convolutional code
% K    : Number of input bits entering the encoder at each clock cycle.
% input: Binary input sequence
% state: State of the convolutional encoder
% termmode='trunc' for no termination with all-0 state 
%Copyleft: Won Y. Yang,, CAU for academic use only
if isempty(G), output=input; return; end
tmp= rem(length(input),K);
input=[input zeros(1,(K-tmp)*(tmp>0))];
if rem(LK,K)>0
  error('The number of column of G must be a multiple of K!')
if nargin<4|(nargin<5 & isnumeric(state))
  input= [input zeros(1,LK)]; %input= [input zeros(1,LK-K)]; end
if nargin<4|~isnumeric(state)
input_length= length(input);
N_msgsymbol= input_length/K;
input1= reshape(input,K,N_msgsymbol);
for l=1:N_msgsymbol % Convolution output=G*input
   ub= input1(:,l).';
   [state,yb]= state_eq(state,ub,G);
   output= [output yb];

Contact us