数字通信技术实验报告

上传人:hh****4 文档编号:204721725 上传时间:2023-04-27 格式:DOCX 页数:15 大小:754.58KB
返回 下载 相关 举报
数字通信技术实验报告_第1页
第1页 / 共15页
数字通信技术实验报告_第2页
第2页 / 共15页
数字通信技术实验报告_第3页
第3页 / 共15页
点击查看更多>>
资源描述
试验一:clear allx,fs,bits=wavread(myheart.wav);z=sign(x); Max=max(abs(x); x1=abs(x/Max); Q=2048*x1;Y=zeros(length(x1),8);for m=1:length(x) if Q(m)128 & Q(m)32 & Q(m)512 & Q(m)16 & Q(m)64 & Q(m)256 & Q(m)1024 & Q(m)0 Y(m,1)=1; elseif z(m)0 Y(m,1)=0; endendN=zeros(1,length(x1);for m=1:length(x1) N(m)=Y(m,2)*4+Y(m,3)*2+Y(m,4)+1;enda=0,16,32,64,128,256,512,1024;b=1,1,2,4,8,16,32,64;for m=1:length(x1) q=ceil(Q(m)-a(N(m)/b(N(m); if q=0 Y(m,(5:8)=0,0,0,0; else k=num2str(dec2bin(q-1,4); Y(m,5)=str2num(k(1); Y(m,6)=str2num(k(2); Y(m,7)=str2num(k(3); Y(m,8)=str2num(k(4); endEnd试验结果:Max =0.3906a =Columns 1 through 7 0 16 32 64 128 256 512Column 8 1024b = 1 1 2 4 8 16 32 64bits =16fs =22050k =111011011m =168873q =476试验二:RGB=imread(8.jpg);I=rgb2gray(RGB);J=dct2(I);imshow(log(abs(J),),colormap(jet(64),colorbarJ(abs(J)=127 image2(i)=255; else image2(i)=0; endendimage3=reshape(image2,512,512);figure,imshow(image3);X=image3(:);x=1:1:length(X);figure,plot(x,X(x);j=1;image4(1)=1;for z=1:1:(length(X)-1) if X(z)=X(z+1) image4(j)=image4(j)+1; else data(j)=X(z); j=j+1; image4(j)=1; endenddata(j)=X(length(X);image4length=length(image4);y=1:1:image4length ;figure,plot(y,image4(y);CR=image2length/image4length;试验三function code = addfade(modcode,Tf,isperiod,isfade)%功能:向传输序列modcode叠加衰落性信道的衰落参数k(t)if(isfade=1) if(isperiod=1) a=31; b=30+10*Tf; modcode(1,a:b)=0.1*modcode(1,a:b);end code=modcode; else code=modcode; endfunction bitcoded = channelcoding(sym,G,k)A=vec2mat(sym,k);%把向量转换成矩阵U=A*G;U=mod(U,2);bitcoded=reshape(U,1,);function bitdecoded = channeldecoding(recode,Etab,Smatrix,H,n,k)%前向纠错函数,实现纠错功能row=length(recode)/n;E=zeros(row,n);RM=zeros(row,n);%纠错之后的矩阵R=vec2mat(recode,n);S=R*H;%伴随矩阵S=mod(S,2);for i=1:rowfor j=1:2(n-k)%查表纠错if(S(i,:)=Smatrix(j,:)E(i,:)=Etab(j,:);RM(i,:)=R(i,:)+E(i,:);RM(i,:)=mod(RM(i,:),2);break;endendendbitdecoded=reshape(RM,1,);%转化为比特流ticclc%功能:有无信道编码性能比较M=2;%进制b=log2(M);%每符号比特数n=128*10000;%符号数G=1 1 1 1 0 0 0;1 0 1 0 1 0 0;0 1 1 0 0 1 0;1 1 0 0 0 0 1;%生成矩阵H=1 0 0 1 1 0 1;0 1 0 1 0 1 1;0 0 1 1 1 1 0;%监督矩阵Etab=0 0 0 0 0 0 0;0 0 0 0 0 0 1;0 0 0 0 0 1 0;0 0 0 0 1 0 0;0 0 0 1 0 0 0;0 0 1 0 0 0 0;0 1 0 0 0 0 0;1 0 0 0 0 0 0;%错误图样Smatrix=Etab*H;%对应的伴随式sym=randint(n,1,M);sym=de2bi(sym,left-msb);bitcoded=channelcoding(sym,G,4);modbit=pskmod(bitcoded,M);%在传输序列modbit加入AWGN噪声snr=0:0.2:15;%噪声为0到15dL=length(snr)%模拟信源编码%信道编码,(7,4)码ser=zeros(1,L);ser2=zeros(1,L);for k=1:Ly=awgn(modbit,10*log10(b)+snr(k),measured);zsym=pskdemod(y,M);%复数解调zbit=de2bi(zsym,left-msb);recode=reshape(zbit,1,);Rstream=recode;err=(Rstream=bitcoded);errnum=sum(err);ser(k)=log10(errnum/length(bitcoded);%纠错bitdecoded=channeldecoding(Rstream,Etab,Smatrix,H,7,4);err=(bitdecoded=bitcoded);errbits=sum(err);ser2(k)=log10(errbits/(length(bitcoded);endplot(snr,ser,b-*)hold onplot(snr,ser2,r-o)grid onlegend(没有信道编码,信道编码);xlabel(Eb/No(dB);ylabel(SER);title(2PSK有无信道编码性能比较);toc%clc;clear;close all;n=10000;b=randint(1,n);f1=1;f2=2;t=0:1/30:1-1/30;%ASKsa1=sin(2*pi*f1*t);E1=sum(sa1.2);sa1=sa1/sqrt(E1); %unit energy sa0=0*sa1;%FSKsf0=sin(2*pi*f1*t);E=sum(sf0.2);sf0=sf0/sqrt(E);sf1=sin(2*pi*f2*t);E=sum(sf1.2);sf1=sf1/sqrt(E);%PSKsp0=-sin(2*pi*f1*t)/sqrt(E1);sp1=sin(2*pi*f1*t)/sqrt(E1);%调制ask=;psk=;fsk=;for i=1:n if b(i)=1 ask=ask sa1; psk=psk sp1; fsk=fsk sf1; else ask=ask sa0; psk=psk sp0; fsk=fsk sf0; endendfigure(1)subplot(411)stairs(0:10,b(1:10) b(10),linewidth,1.5)axis(0 10 -0.5 1.5)title(Message Bits);grid onsubplot(412)tb=0:1/30:10-1/30;plot(tb, ask(1:10*30),b,linewidth,1.5)title(ASK Modulation);grid onsubplot(413)plot(tb, fsk(1:10*30),r,linewidth,1.5)title(FSK Modulation);grid onsubplot(414)plot(tb, psk(1:10*30),k,linewidth,1.5)title(PSK Modulation);grid onxlabel(Time);ylabel(Amplitude)%AWGNfor snr=0:30 askn=awgn(ask,snr); pskn=awgn(psk,snr); fskn=awgn(fsk,snr); %DETECTION A=;F=;P=; for i=1:n %ASK Detection if sum(sa1.*askn(1+30*(i-1):30*i)0.5 A=A 1; else A=A 0; end %FSK Detection if sum(sf1.*fskn(1+30*(i-1):30*i)0.5 F=F 1; else F=F 0; end %PSK Detection if sum(sp1.*pskn(1+30*(i-1):30*i)0 P=P 1; else P=P 0; end end %BER errA=0;errF=0; errP=0; for i=1:n if A(i)=b(i) errA=errA; else errA=errA+1; end if F(i)=b(i) errF=errF; else errF=errF+1; end if P(i)=b(i) errP=errP; else errP=errP+1; end end BER_A(snr+1)=errA/n; BER_F(snr+1)=errF/n; BER_P(snr+1)=errP/n;endfigure(2)subplot(411)stairs(0:10,b(1:10) b(10),linewidth,1.5)axis(0 10 -0.5 1.5);grid ontitle(Received signal after AWGN Channel)subplot(412)tb=0:1/30:10-1/30;plot(tb, askn(1:10*30),b,linewidth,1.5)title(Received ASK signal);grid onsubplot(413)plot(tb, fskn(1:10*30),r,linewidth,1.5)title(Received FSK signal);grid onsubplot(414)plot(tb, pskn(1:10*30),k,linewidth,1.5)title(Received PSK signal);grid onfigure(3)semilogy(0:30,BER_A, b,linewidth,2)title(BER Vs SNR)grid on;hold onsemilogy(0:30,BER_F,r,linewidth,2)semilogy(0:30,BER_P, k,linewidth,2)xlabel(Eo/No(dB)ylabel(BER)hold offlegend(ASK,FSK,PSK);试验四clcclear%Generationofbitpatterns=round(rand(1,25);signal=;%Generating20bitscarrier=;t=0:2*pi/119:2*pi;for k=1:25 %Creating60samplesforonecosine if s(1,k)=0 sig=-ones(1,120); %120minusonesforbit0 %120onesforbit1 else sig=ones(1,120); end c=cos(t); carrier=carrier c; signal=signal sig;endsubplot(4,1,1);plot(signal);axis(-100 3100 -1.5 1.5);title(bfit Original Bit Sequence);%BPSKModulationofthesignalbpsk_sig=signal.*carrier;subplot(4,1,2);%Modulatingthesignalplot(bpsk_sig)axis(-100 3100 -1.5 1.5);title(bfit BPSK Modulated Signal);%Preparationof6newcarrierfrequenciest1=0:2*pi/9:2*pi;t2=0:2*pi/19:2*pi;t3=0:2*pi/29:2*pi;t4=0:2*pi/39:2*pi;t5=0:2*pi/59:2*pi;t6=0:2*pi/119:2*pi;c1=cos(t1);c1=c1 c1 c1 c1 c1 c1 c1 c1 c1 c1 c1 c1;c2=cos(t2);c2=c2 c2 c2 c2 c2 c2;c3=cos(t3);c3=c3 c3 c3 c3;c4=cos(t4);c4=c4 c4 c4;c5=cos(t5);c5=c5 c5;c6=cos(t6);%Randomfrequencyhoppstoformaspreadsignalspread_signal=;for n=1:25 c=randint(1,1,1 6); switch(c) case(1) spread_signal=spread_signal c1; case(2) spread_signal=spread_signal c2; case(3) spread_signal=spread_signal c3; case(4) spread_signal=spread_signal c4; case(5) spread_signal=spread_signal c5; case(6) spread_signal=spread_signal c6; endendsubplot(4,1,3)plot(1:3000,spread_signal);axis(-100 3100 -1.5 1.5);title(bfit Spread Signal with 6 frequencies);%SpreadingBPSKSignalintowiderbandwithtotalof12frequenciesfreq_hopped_sig=bpsk_sig.*spread_signal;subplot(4,1,4)plot(1:3000,freq_hopped_sig);axis(-100 3100 -1.5 1.5);title(bfit Frequency Hopped Spread Spectrum Signal);%ExpressingtheFFTsfigure,subplot(2,1,1)plot(1:3000,freq_hopped_sig);axis(-100 3100 -1.5 1.5);title(bfit Frequency Hopped Spread Spectrum signal and its FFT);subplot(2,1,2);plot(1:3000,abs(fft(freq_hopped_sig);
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 工作计划


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!