rsencof.m

来自「数字通信第四版原书的例程」· M 代码 · 共 45 行

M
45
字号
function rsencof(file_in, file_out, err_cor);
%RSENCOF Reed-solomon encode for an ASCII file.
%       RSENCOF(FILE_IN, FILE_OUT) encodes an ASCII file FILE_IN using
%       codeword length 127, message length 117 Reed-Solomon code. The
%       error-correction capability of this code is 5 (for every 127
%       character). The encoded code is written to FILE_OUT. Both
%       FILE_IN and FILE_OUT are string variable.
%
%       RSENCOF(FILE_IN, FILE_OUT, ERR_COR) encodes an ASCII file FILE_IN
%       using codeword length 127, error-correction capability as ERR_COR
%       Reed-Solomon code. The message length is 127 - 2*ERR_COR.
%
%       See also RSDECOF.

%       Wes Wang 10/11/95.
%       Copyright (c) 1995-96 by The MathWorks, Inc.
%       $Revision: 1.1 $  $Date: 1996/04/01 18:03:09 $


if nargin < 3
    err_cor = 5;
end;
N = 127;
K = 127 - err_cor * 2;

%file read in
h = fopen(file_in, 'r');
if h < 0
    error(['File ', file_in, ' does not exist.']);
end;
x = fread(h, 'char');
fclose(h);

x = vec2mat(x, K, setstr(4));

code = encode(x, N, K, 'rs/decimal')';

code = code(:)';
h = fopen(file_out, 'w');
fwrite(h, code, 'char');

% end of rsencof.m


⌨️ 快捷键说明

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