📄 gold.m
字号:
% This code is written for educational purpose.
% This Gold code generator is using (5,3) and (5,4,3,2) ML generators.
% If you have any question, contact Prof. Hyoung Joong Kim
% through khj@kangwon.ac.kr
% Ra is the (5,3) ML generator.
% Rb is the (5,4,3,2) ML generator.
% Output Rc has the Gold sequence generated.
% The length of the Gold sequence is 2^5-1.
% The values of Rc depends on the initial values of Ra and Rb.
% In this example, initial values of Ra and Rb are all ones.
clear;
Ra=ones(1,5);
Rb=ones(1,5);
for i=1:31
Rc(i)=mod(Ra(5)+Rb(5),2);
Ra=[mod(Ra(3)+Ra(5),2) Ra(1:4)];
Rb=[mod(Rb(2)+Rb(3)+Rb(4)+Rb(5),2) Rb(1:4)];
end
Ra=[1 0 1 1 1];
Rb=ones(1,5);
for i=1:31
Rd(i)=mod(Ra(5)+Rb(5),2);
Ra=[mod(Ra(3)+Ra(5),2) Ra(1:4)];
Rb=[mod(Rb(2)+Rb(3)+Rb(4)+Rb(5),2) Rb(1:4)];
end
plot(xcorr((2*Rc-1),(2*Rd-1)))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -