?? test5.asv
字號:
%%%%%%%%%%%%%%%擴頻通信--加載波發射為隨機碼%%%%%%%%%%%%%%%%%%
close all;
clear all;
clc;
fs1=3e3;%帶寬
fs3=15e3;%采樣頻率
fs2=4.5e3;%載波頻率
m=6;%偽碼m
tb1=1/fs1;
tb2=1/fs2;
tb3=1/fs3;
f02=pcode1(m);%產生m階為隨機序列
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);
% fid = fopen('D:\vcproject\Voice Spread-spectrum communication\Emission\xishu4.txt','rt');%%打開文件,并獲得句柄
% [y,count]=fscanf(fid,'%lg',inf);
% fclose(fid);%關閉文件
% y=y.';
%
% figure
% plot(code2,'r')
% hold on;
% plot(y,'g')
% axis([1 count+10 -1.5 1.5]);
%
% clear mod4;
figure
plot(tz1)
% figure;plot(10*log10(abs(fft(y(1:1.6e4)))),'g');
% hold on;
% plot(10*log10(abs(fft(tz1(1:1.6e4)))),'r');
num6=length(tz1);
% break;
% [mpeg] = readdata(num6,tb3,fs3);
% noise1=rand(1,num6);
% figure
% plot(noise1)
% noise1=rand(1,num6);
% gg=num6;%%接受的點數
% fid = fopen('D:\zhijierand38doub.DAT','r');%%打開文件,并獲得句柄
% fseek(fid,0,'bof');%1.4e6
% [y,count]= fread(fid,gg,'float');%讀出數據
% fclose(fid);%關閉文件
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);
%+0.5.*sin5k(1:y_number);
% tz2 = tz2./max(abs(tz2));
% clear noise1;
x=abs(fft((tz1(1,1:1.6e4))));
x=10*log10(x);
figure
plot(x);
% tz2 = tz2./max(abs(tz2));
% tz2 = fix(tz2.*32767);
% tz2(1:10)
% figure
% plot(tz2);
% figure
% plot(0.1*f01)
% % tz2=(0.01*f01).*mpeg;
% fid = fopen('D:\singal102.dat','w');
% fseek(fid,0,'bof');
% count= fwrite(fid,tz2,'float');
% fclose(fid);
tz2 = tz1(1:y_number) + y(1:y_number);%1.*
filename = 'send_1.wav';
wavwrite(tz2,fs3,filename);
% plot(10*log10(abs(fft(tz2(1:1.6e4)))));
wavplay(tz2,fs3);
%%%%%%%%相關性分析%%%%%%%%%%%
% b3=xcorr(y(1:2000),y(1:2000));
% b3=abs(b3);
% figure
% plot(b3);
% title('音樂信號的相關圖')
% y_number =2000;
% b3=xcorr(tz1(1:y_number),tz1(1:y_number));
% b3=abs(b3);
% figure
% bar(b3);
% title('傳輸信息的相關圖')
% tz3 = y;
% figure;
% plot(y);
% m = 44;
% w = zeros(1,m);
% k = 10;
% u = 0.3;
% min = 1e-9;
% for n=m+k:1:1.6e4+m+k
% e_guess(n-m+k+1) = sum(w.*tz3(n-k:-1:n-k-m+1));
% e(n) = tz3(n) - sum(w.*tz3(n-k:-1:n-k-m+1));
% w = w+(u*e(n).*tz3(n-k:-1:n-k-m+1))./(min+sum(tz3(n-k:-1:n-k-m+1).*tz3(n-k:-1:n-k-m+1)));
% end
% e = e(m+k:1.6e4+m+k);
% e_length = length(e);
% figure;
% plot(e,'r');
% hold on;
% plot(e_guess,'b');
% hold on;
% plot(y(1:e_length),'g');
%
% % figure;
% % plot(tz3(1:1.6e4));
% % figure;
% % plot(y(1:1.6e4));
% figure;
% plot(10*log10(abs(fft(e(1:1.6e4)))),'g');
% hold on;
% plot(10*log10(abs(fft(y(1:1.6e4)))),'b');
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -