pngen.m
来自「These files in Matlab implement a conven」· M 代码 · 共 24 行
M
24 行
%% Generation of PN sequence with a given length N , given input state
%% and a generator polynomial
% Note : Length of the generator polynomial is equal to N and is in the
% following form :- s
% Positions 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
% Gen_Poly= [ 1 0 1 0 0 0 1 1 1 0 1 0 0 0 1]
function [y]=PNgen(N,gen_poly);
intial_state = [zeros(length(gen_poly)-1, 1); 1];
final_state=zeros(1,N);
pn_seq=[];
for i=1:N
final_state(2:end)=intial_state(1:end-1);
final_state(1)=mod(sum(intial_state(find(gen_poly(2:end)))),2);
pn_seq(i)=final_state(N);
intial_state=final_state;
end
y=pn_seq;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?