📄 pnsequence.m
字号:
function pn = pnsequence(genPoly,initState,sqLength)
%PNSEQUENCE Generate Pseudo-Noise(PN) sequence using LFSR
% (Linear Feedback Shift Registers)
%
% PN = PNSEQUENCE(GENPOLY,INITSTATE,SQLENGTH)
%
% GENPOLY: Generator Polynomial f(x) = 1 + f1.x + f2.x^2 + ...+ f_r.x^r
% GEN_POLY = [1 f1 f2 ... f_r]
% INITSATE: Initial sate of the shift registers [x1 x2 .... xr]
% SQLENGTH: Length of the PN Sequence
%
% Nguyen Thanh Hieu
% Multimedia Signal Processing Lab
% Information and Communication Engineering Department
% Yeungnam University, Korea
registerState(1,1:length(initState)) = initState;
for j = 1:sqLength
%1-time cyclicly right-shift
registerState(j+1,:) = circshift(registerState(j,:),[0 1]);
%Modulo-2 adder
registerState(j+1,1) = mod(sum(genPoly(2:end) .* registerState(j,:)),2);
end
pn = registerState(1:sqLength,length(initState))';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -