this is the block diagram
my code is like this:
function [ y1,y2,D1,D2 ] = Encoder(input)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
length_input = length(input);
y1(1) = input(1);
D1(1) = 0;
D2(1) = 0;
y2(1) = input(1);
for i = 2:length_input
y1(i) = input(i);
y2(i) = xor(input(i),D2(i-1));
D1(i) = xor(y2(i-1),input(i));
D2(i) = xor(D1(i-1),y2(i-1));
end
end
i insert a group of date [1 1 0 1 1 0 0 0]
using the state machine ,the output should be [11 10 01 10 10 01 00 01]
but i run my code and got a set of wrong output which is [11 11 01 10 11 00 00 01]
could you please see if there is any problem in my code?