📄 find_codegenerator.m
字号:
function [g,varargout] = ... find_codegenerator(CGFile, coderate, constraint_length, varargin);%------------------------------------------------------------------------------% Find maximum free distance non-systematic code generator polynomials % for convolutional codes, or recursive systematic code generator% polynomials for turbo codes.% % Format:% -------% % Convolution:% [g, [gen_form]] = ...% find_codegenerator(CGFile, coderate, constraint_length, ['non-recursive'])% % Turbo:% [g, [gen_form]] = ...% find_codegenerator(CGFile, coderate, constraint_length, 'recursive')%% % Author: MVe% Date: 26.07.2002%------------------------------------------------------------------------------% Check function call formattmp = length(varargin);if tmp>0 if tmp == 1 gen_type = varargin{1}; if ~or(strmatch(gen_type, 'non-recursive'),strmatch(gen_type, 'recursive')) error(sprintf('Unknown encoder / decoder type ''%s''', gen_type)); end % if ~or(strmatch(gen_type, 'non-recursive'), ... end % if tmp == 1else if tmp==0 gen_type = 'non-recursive'; else error('Wrong number of arguments'); end % if tmp==0 end % if tmp~=0% Coderate in string-format[det div] = rat(coderate);coderate_s = [num2str(det) '/' num2str(div)];% Check if coderate is validswitch gen_type case 'non-recursive' if sum([det~=1, div>4, div<2])>0 error('Only coderates 1/k, k = 2,3,4 for NSC supported'); end % if sum([det~=1, div>4, div<2])>0 case 'recursive' if sum([det~=1, div>3, div<2])>0 error('Only coderates 1/k, k = 2,3 for RSC supported'); end % if sum([det~=1, div>3, div<2])>0end % switch gen_typetmp = textread(CGFile,'%s','delimiter','\n','whitespace','',... 'commentstyle','c++');MatchB = ['#define CodeRate ', coderate_s, ' begins'];BCode = strmatch(MatchB,tmp);MatchE = ['#define CodeRate ', coderate_s, ' ends'];ECode = strmatch(MatchE,tmp);switch gen_type case 'non-recursive' CodeGens = tmp(BCode(1)+1:ECode(1)-1); case 'recursive' CodeGens = tmp(BCode(2)+1:ECode(2)-1);end % switch gen_type % Clean-up redundant information (empty lines, comments)i = 1;while i <= length(CodeGens) if isempty(double(CodeGens{i})) CodeGens(i) = []; else i = i+1; endendCodeGens(strmatch('%',CodeGens)) = [];% Insert correct generator polynomial to variable 'CodeGenerator'eval(CodeGens{constraint_length-1});if isempty(CodeGenerator) error(sprintf('Codegenerator for %s-rate, K=%d, %s encoder not found ', ... coderate_s,constraint_length,gen_type));else g = CodeGenerator;end % if isempty(Codegenerator) % Codegenerator is in octal-formvarargout{1} = 'octal';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -