?? duiou.m
字號:
function out_code = duiou(f,d,code_dec);
%對偶頻帶法產(chǎn)生寬間隔跳頻序列
% clear;
% clc;
%生成頻隙集合
% f = 0:16;
%間隔寬度
% d = 3;
%頻隙數(shù)目
q = length(f);
temp = floor(q/2);
pow = nextpow2(temp);
if(2.^pow>temp)
pow = pow-1;
end
%確定頻帶F1和F2
% F1 = 0:(floor(q/2)-1);
% F2 = (q-floor(q/2)):f(end);
F1 = 0:(2.^pow-1);
F2 =(q-2.^pow):(q-1);
%建立對偶頻隙,第一行為F1中的頻隙,第二行為與之對應(yīng)的F2中的頻隙
corresponding_table = [F1;F2];
%根據(jù)參數(shù)選取選擇合適的碼字
% load code_dec31;
% code_dec = code_dec31;%進行符號轉(zhuǎn)換,便于選擇不同碼字,不必修改下面程序。
%下面的算法中隱含code_dec和F1一一對應(yīng).即0:length(code_dec) == F1
%生成寬間隔序列
for i = 1:size(code_dec,1)
%當(dāng)前跳頻的頻帶
%標(biāo)記窄點
narrow_tag = zeros(1,size(code_dec,2));
for index = 2:size(code_dec,2)
if(abs(code_dec(i,index)-code_dec(i,index-1))<(d+1))
narrow_tag(index-1) = 1;
end
end
if(abs(code_dec(i,index)-code_dec(i,1))<(d+1))
narrow_tag(end) = 1;
end
%判斷窄點個數(shù)是否滿足要求
if(mod(sum(narrow_tag),2) == 0)%不滿足窄點個數(shù)要求
wide_index = find(narrow_tag == 0);
narrow_tag(wide_index(1)) = 1;
end
now_row = 1;%行標(biāo)志用于選取頻帶:1選擇F1,2選擇F2
now_col = 1;%用于選擇code_dec所對應(yīng)的列
S_wide(i,1) = code_dec(i,1);
for j = 2:(2*size(code_dec,2))
%判斷當(dāng)前位置的點是否是窄點
if(narrow_tag(now_col) == 1)
%如果是窄點,進行頻帶跳變,并且列下標(biāo)變化
if now_row == 1
now_row = 2;
else
now_row =1;
end
now_col = now_col+1;
if(now_col > size(code_dec,2))
now_col = 1;
end
else
%如果不是窄點,只是列下標(biāo)變化
now_col = now_col+1;
if(now_col > size(code_dec,2))
now_col = 1;
end
end
%由code_dec(i,now_col)選取corresponding_table中的列索引
col = code_dec(i,now_col)+1;
if(col>length(F1))
col = 1;
end
S_wide(i,j) = corresponding_table(now_row,col);
end
end
out_code =S_wide;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -