Viterbi algorith for trellis traceback

2 views (last 30 days)
Mohamad Khalil
Mohamad Khalil on 17 Jan 2021
Commented: Mohamad Khalil on 22 Jan 2021
Hello,
i am trying to simulate GSM and i have s function called FCN_VITERBI that generate table for trellis, metrics and metric differences and then trys to find the last state and traceback the trellis based on viterbi algorithm.
At the end i am trying to show the trellis by using the following function:
function [C] = showTrellis(S,bEst,sTrace)
len = 10;
figure(30)
clf
C = [0 1 0; 0 1 0; 0 1 0; 0 1 0;1 0 0; 1 0 0; 1 0 0; 1 0 0];
%plot([1,2],[(1:8)',S(:,1)]','-o');
hold on
for i = 0:len - 2
P = plot([2,1]+i,[(0:7)',S(:,2+i)-1]','-o','Linewidth',3); %the error position
%plot([2,1]+i,[(0:7)',S(:,2+i)-1]','-o','Linewidth',3);
for j = 1:8
P(j).Color = C(j,:);
end
text(i + 1.4,-.5,num2str(bEst(i+1)),'FontSize',14);
end
plot(sTrace(1:len)-1,'--k','Linewidth',3);
title('Trellis Diagram');
end
but i get the following error:
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error in showTrellis (line 10)
P = plot([2,1]+i,[(0:7)',S(:,2+i)-1]','-o','Linewidth',3);
%some infos
length(S) = 62
length(h) = 6
length(y) = 66
L = 5
length( r ) = 64
length(ini_S) = 1
tail_R = [111]
can someone please help?
Thanks

Answers (1)

Gaurav Garg
Gaurav Garg on 20 Jan 2021
Hi Mohamad,
You should try printing individual arrays [2,1]+i and [(0:7)',S(:,2+i)-1]' and ensure that the array sizes are same.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!