pngen.m

来自「is95系统的基带仿真程序。自己可以去调试」· M 代码 · 共 25 行

M
25
字号
function [y, Z] = PNGen(G, Zin, N);
%
% PN_GEN		This function generates the Pseudo Noise sequnece of length (N)
%				according to Generation Polynom and input state.
%
% 						Inputs: G - Generation Polynom
%                         Zin - Initial state of Shift register
%                         N - The length of PN sequence
%
% 						Outputs: y - The resulting PN sequence
%                          Z - The output state of Shift register
%

L = length(G);
Z = Zin;    % initialize input state of shift register

y = zeros(N, 1);
for i=1:N
   y(i) = Z(L);
   Z = xor(G*Z(L), Z);
   Z = [Z(L); Z(1:L-1)];
end   
%yy = filter(1, flipud(G), [1; zeros(N-1, 1)]);
%yy = mod(yy, 2);

⌨️ 快捷键说明

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