You have already been told what the problem is: http://www.mathworks.com/matlabcentral/answers/26596-viterbi-decoder
You create
trel=poly2trellis(4,[13 15], 13);
trellis = poly2trellis(ConstraintLength,CodeGenerator) performs the conversion for a rate k/n feedforward encoder. ConstraintLength is a 1-by-k vector that specifies the delay for the encoder's k input bit streams. CodeGenerator is a k-by-n matrix of octal numbers that specifies the n output connections for each of the encoder's k input bit streams.
Now your first argument is 1-by-1 and that must match 1-by-k so we deduce that your k is 1. And then your second argument is 1-by-2 and that must match k-by-n and we figured k is 1 so we are matching 1-by-n and thus we deduce that n is 2.
Then we read down further and see that the output structure includes
numOutputSymbols Scalar Number of output symbols from the encoder: 2^n
and as we have figured that n is 2, we deduce that numOutputSymbols will be 2^2 = 4.
Your problem is occurring in the vitdec step and as we discussed before, log2(trel.numInputSymbols) must evenly divide length(decode1). So log2(4) must evenly divide length(decode1), so 2 must evenly divide length(decode1)
At this point you must debug your program and check what length(decode1) actually is. Especially on the second round (i=2)
