?? test5.m
字號:
%%%%%%%%%%%%%%%擴頻通信--加載波發射為隨機碼%%%%%%%%%%%%%%%%%%
close all;
clear all;
clc;
fs1=3e3;%帶寬
fs3=15e3;%采樣頻率
fs2=4.5e3;%載波頻率
m=10;%偽碼m
tb1=1/fs1;
tb2=1/fs2;
tb3=1/fs3;
f02=pcode1(m);%產生m階為隨機序列
% f02 = -1*f02;
% f03 = f02;
% for i =1:1:10
% f03 = [f03 , f02];
% end
% figure
% plot(xcorr(f03,f02));
% break;
figure
plot(f02);
shuzi1=[49:1:52];%傳輸的信息
[code1]=product1(shuzi1);%把信息轉化成2進制
%%%%%%%%%%%%%%%添加同步頭和同步尾%%%%%%%%
head1=[1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0];
end1=[0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1];
code2 = [head1 code1];
code2=[code2,end1];
clear head1;
clear code1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure
plot(code2)
[mod2]=modtion2(f02,code2);%通信信息用為隨機碼來調制
figure
plot(mod2)
[mod3,num2]=dpsk1(mod2);%2DPSK調制
[mod4]=modtion3(mod3,tb1,tb3,fs1,fs3);%內插5個點
figure
plot(mod4)
clear mod3;
[tz1,sin5k]=modtion1(mod4,tb1,tb2,tb3,fs2,fs3);%正弦調制
figure
plot(tz1)
%%%%%%%%%%%%%%%%%%%%%讀取音樂文件并歸一化%%%%%%
num6=length(tz1);
wavfile = 'D:\我的研究\擴頻通信之顧\語音擴頻通信\發射的數據文件\last_181.wav';
[y,fs3 , nbits] = wavread(wavfile);
y=y.';
y = y(1,:);
y=y(1:num6);
y_max=max(abs(y));
y=y./y_max;
y_number=length(y);
x=abs(fft((tz1(1,1:1.6e4))));
x=10*log10(x);
figure
plot(x);
tz2 = tz1(1:y_number) + y(1:y_number);%1.*%信號和音樂相加
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%寫入文件%%%%%%%%%%%%%%%%%%
% filename = 'send_1.wav';
% wavwrite(tz2,fs3,filename);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wavplay(tz2,fs3);%播放文件
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -