%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function outvec = ovsf(sf, code)
% outvec = ovsf(class, code)
% HADAMARD SEQUENCES.
% sf = spreading factor of the code.
% Class = log of the spreading factor of the OVSF code:- ie, Class = log2(SF).
% Code = code number from the particular branch.
% ----------------- Completed By Charan Litchfield --------------------------------
% ------------------------- 6/10/03 -----------------------------------------------
% ---------------------------17:27-------------------------------------------------
% ---------------------------------------------------------------------------------
if nargin ~= 2
error('Must have two input arguments');
end
class = log2(sf);
[m, n] = size(class);
if (m~=1 | n~= 1)
error('First input argument must be a scalar');
end
if (fix(class) ~= class | class < 1 | class > 12)
error('First input argument must be an integer between 1 and 12');
end
[m, n] = size(code);
if (m~=1 | n~= 1)
error('Second input argument must be a scalar');
end
if (fix(code) ~= code | code < 0 | code > pow2(class)-1)
error('Second input argument must be an integer between 0 and pow2(class)-1.');
end
h = 1;
for i = 1:class
h = [h h; h -h];
end
outvec = h(code+1, :);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function outvec = dllsc(scgroup, pgroup, sgroup, alt)
% outvec = dllsc(scgroup, pgroup, sgroup, alt).
% Gold Code Generator.
% scgroup must be 0...63.
% pgroup must be 0...7.
% sgroup must be 0...15.
% alt selects the scrambling code for the downlink operation.
% ------------------------ written by Charan Litchfield ---------------------------
% --------------------------------6/10/03------------------------------------------
% --------------------------------18:10--------------------------------------------
if nargin ~= 4
error('Need to input four arguments: scgroup (0..63), pgroup (0..7), sgroup (0..15) and alt (0..2).');
end
[m, n] = size(scgroup);
if (m~=1 | n~= 1)
error('Input arguments must be scalar');
end
if (scgroup<0 | scgroup>63)
error('scgroup is outside the range 0..63');
end
[m, n] = size(pgroup);
if (m~=1 | n~= 1)
error('Input arguments must be scalar');
end
if (pgroup<0 | pgroup>7)
error('pgroup is outside the range 0..7');
end
[m, n] = size(sgroup);
if (m~=1 | n~= 1)
error('Input arguments must be scalar');
end
if (sgroup<0 | sgroup>15)
error('sgroup is outside the range 0..15');
end
[m, n] = size(alt);
if (m~=1 | n~= 1)
error('Input arguments must be scalar');
end
switch alt
case 0
n = 16.*(8.*scgroup+pgroup)+sgroup; % no compressed mode, code number = 0..8191
case 1
n = 16.*(8.*scgroup+pgroup)+sgroup+8192; % compressed mode left alternative, code number = 8192..16383
case 2
n = 16.*(8.*scgroup+pgroup)+sgroup+16384; % compressed mode right alternative, code number = 16384..24575
otherwise
error('alt is outside the range 0..2');
end
x = [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; % initialize x shift register
y = [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]; % initialize y shift register
% we need x(i+n), so run x free for n chips
for i=1:n
temp = x(18);
x(18) = (x(1)|x(8)) &~(x(1)&x(8)); % faster than xor(x(1), x(8))
x(1:16) = x(2:17);
x(17) = temp;
end
% now generate first 38400 chips of downlink long scrambling code
outvec(1:38400) = 1+1i; % mem preallocation to speed up
for i = 1:38400
rl = (x(1)|y(1)) & ~(x(1)&y(1));
temp = y(6)+y(7)+y(9)+y(10)+y(11)+y(12)+y(13)+y(14)+y(15)+y(16)+x(5)+x(7)+x(16);
temp = temp - 2.*fix(temp./2);
outvec(i) = complex(1-2.*rl, 1-2.*temp); % output as a complex number
temp = x(18);
x(18) = (x(1)|x(8)) & ~(x(1)&x(8));
x(1:16) = x(2:17);
x(17) = temp;
temp = y(18);
y(18) = y(1) + y(6) + y(8) + y(11);
y(18) = y(18) - 2.*fix(y(18)./2);
y(1:16) = y(2:17);
y(17) = temp;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Spreading::::::::::::::::::::
%%%% Generate data/modulation Vector - called d %%%%%%%%%%%%%%
for n = 1:length(d)
Spreaded_Data(:,1+(n-1)*length(code):n*length(code)) = d(:,n)*code;
end
% Scramble
Y = Spreaded_Data.*Scrambling_Code(1:length(Spreaded_Data));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Despreading %%%%%%%%%%%%%%%%%%%%
X = Y.*Scrambling_Code(1:length(Spreaded_Data)); % Descramble First
for n = 1:length(d)
Despread(:,n) = code*X(:,1+(n-1)*length(code):n*length(code))';
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ocdma.zip_OCDMA IN MATLAB _OCDMA Orthogonal_Orthogonal code_ocd
版权申诉
64 浏览量
2022-07-14
13:35:30
上传
评论
收藏 5KB ZIP 举报
邓凌佳
- 粉丝: 65
- 资源: 1万+
最新资源
- 重磅推荐上市公司专利数据大全1990-2022年 创新产出投入创新质量
- 2024年管理世界全文复现《人工智能如何提升企业生产效率?》(劳动力技能结构调整)
- 地级市到所在省份省会距离、到杭州距离
- 更新stata显著性调节、调显著(显著性符号、中介效应、调节效应、DID模型)
- 基于QT+C++实现的带动画效果的多选框QCheckBox+源码
- 股价崩盘风险、周收益率的均值与标准差计算数据和Stata代码(2000-2020)NCSKEW DUVOL
- (实证)数据复现:创新型城市绿色发展:效率测算、外部性与提升路径
- LSTM行为识别 in Python
- ☆☆☆已更新到2022年☆☆☆史上最全的TobinQ数据2003-2022年 托宾Q<<<
- 大数据-Python数据可视化-Matplotlib实战:Matplotlib绘图
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈