📄 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 + -