untitled.m

来自「this file consists of many matlab progra」· M 代码 · 共 28 行

M
28
字号
%A cyclic code is a linear block code with the property that cyclic shifts
%of a codeword (expressed as a series of bits) are also codewords
clear;
clc;
 % Set codeword length and message length
n = input(' enter the length of codeword ');
k = input(' enter the length of message ');
% Message is a binary column.
msg = input(' enter the message ');
%The cyclpoly function produces generator polynomials for cyclic codes.
%genpoly = cyclpoly(n,k)
genpoly=[1 1 0 1]
%To find a parity-check and generator matrix for a cyclic code, use the
%cyclgen function
[parmat,genmat] = cyclgen(n,genpoly)
code = encode(msg,n,k,'cyclic',genpoly)
%gfweight turns the minimum distance of the cyclic code whose codeword
%length is n and whose generator polynomial is represented by genpoly.
wt = gfweight(genpoly,n)
% Produce decoding table
trt = syndtable(parmat)
%decodes the cyclic code code and tries to correct errors using the decoding
%table trt, where trt is a 2^(n-k)-by-n matrix. genpoly is a row vector 
%that gives the coefficients, in order of ascending powers, of the binary 
%generator polynomial of the code. the number of errors detected in ERR a negative integer indicates that there are more errors than can be corrected.
%the corrected codeword CCODE vector cerr the number of errors corrected in the rth codeword
[msg,err,ccode,cerr]= decode(code,n,k,'cyclic',genpoly,trt)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?