% Decoder for Systematic (N,K) Cyclic Codes function M = CyclicDecoder(R, P, T) % Define N, K, DegPoly K = length(R); % K is the length of Received Code N = length(P); % N is length of Polynomial DegPoly = N - 1; LFSR = zeros(1, N - K); for i = 1:K feedback = R(i); % compute feedback disp(['Input message: ', num2str(R(i)), ', Current LFSR: ', num2str(LFSR), ', feedback: ', num2str(feedback)]); for j = DegPoly:-1:2 if (P(j) == 1) LFSR(j) = rem((LFSR(j - 1) + feedback), 2); else LFSR(j) = LFSR(j - 1); end end LFSR(1) = feedback; disp(['Next LFSR: ', num2str(LFSR)]); end SYN = mod(conv(R, P), 2); % compute syndrome using convolution index = bi2de(SYN, 'left-msb'); % get index value from binary syndrome ErrorPattern = T(index + 1, :); Uhat = mod(R + ErrorPattern, 2); % Correct R using ErrorPattern M = Uhat(1:K); % Extract the message part from corrected Codeword end


M = [1 0 1 1]; P = [1 1 0 1];

C = [1 0 0 1 0 1 0];

T = syndtable(cyclgen(length(ReceivedCodeword), P, 'system'));


이건데 자꾸 인덱스 오류나는데 뭐가 문제임?