1、数字通信技术实验报告实验一:clearallx,fs,bits=wavread(myheart.wav);z=sign(x); Max=max(abs(x); x1=abs(x/Max); Q=2048*x1;Y=zeros(length(x1),8);form=1:length(x)ifQ(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;elseifz(m)0 Y(m,1)=0;endendN=zeros(1,length(x1);form=1:length(x1)N(m)=Y(m,2)*4+Y(m,3)
2、*2+Y(m,4)+1;enda=0,16,32,64,128,256,512,1024;b=1,1,2,4,8,16,32,64;form=1:length(x1)q=ceil(Q(m)-a(N(m)/b(N(m);ifq=0 Y(m,(5:8)=0,0,0,0;elsek=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=Columns1through70 16 32 64 128 2565
3、12Column81024b=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)=127image2(i)=255;elseimage2(i)=0;endendimage3=reshape(image2,512,512);figure,imshow(image3);X=image3(:);x=1:1:length(X);figure
4、,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;elsedata(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;实验三functioncode=addfade(modcode,Tf,isperiod,isfade
5、)%功能:向传输序列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);endcode=modcode;elsecode=modcode;endfunctionbitcoded=channelcoding(sym,G,k)A=vec2mat(sym,k);%把向量转换成矩阵U=A*G;U=mod(U,2);bitcoded=reshape(U,1,);functionbitdecoded=channeldecoding(recode,Etab,Sma
6、trix,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);fori=1:rowforj=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%功能:有无信
7、道编码性能比较M=2;%进制b=log2(M);%每符号比特数n=128*10000;%符号数G=1111000;1010100;0110010;1100001;%生成矩阵H=1001101;0101011;0011110;%监督矩阵Etab=0000000;0000001;0000010;0000100;0001000;0010000;0100000;1000000;%错误图样Smatrix=Etab*H;%对应的伴随式sym=randint(n,1,M);sym=de2bi(sym,left-msb);bitcoded=channelcoding(sym,G,4);modbit=pskmo
8、d(bitcoded,M);%在传输序列modbit加入AWGN噪声snr=0:0.2:15;%噪声为0到15dL=length(snr)%模拟信源编码%信道编码,(7,4)码ser=zeros(1,L);ser2=zeros(1,L);fork=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);se
9、r(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-*)holdonplot(snr,ser2,r-o)gridonlegend(没有信道编码,信道编码);xlabel(Eb/No(dB);ylabel(SER);title(2PSK有无信道编码性能比较);toc
10、%clc;clear;closeall;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);%unitenergysa0=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
11、(E1);%调制ask=;psk=;fsk=;fori=1:nifb(i)=1ask=asksa1;psk=psksp1;fsk=fsksf1;elseask=asksa0;psk=psksp0;fsk=fsksf0;endendfigure(1)subplot(411)stairs(0:10,b(1:10)b(10),linewidth,1.5)axis(010-0.51.5)title(MessageBits);gridonsubplot(412)tb=0:1/30:10-1/30;plot(tb,ask(1:10*30),b,linewidth,1.5)title(ASKModulati
12、on);gridonsubplot(413)plot(tb,fsk(1:10*30),r,linewidth,1.5)title(FSKModulation);gridonsubplot(414)plot(tb,psk(1:10*30),k,linewidth,1.5)title(PSKModulation);gridonxlabel(Time);ylabel(Amplitude)%AWGNforsnr=0:30askn=awgn(ask,snr);pskn=awgn(psk,snr);fskn=awgn(fsk,snr);%DETECTIONA=;F=;P=;fori=1:n%ASKDete
13、ctionifsum(sa1.*askn(1+30*(i-1):30*i)0.5A=A1;elseA=A0;end%FSKDetectionifsum(sf1.*fskn(1+30*(i-1):30*i)0.5F=F1;elseF=F0;end%PSKDetectionifsum(sp1.*pskn(1+30*(i-1):30*i)0P=P1;elseP=P0;endend%BERerrA=0;errF=0;errP=0;fori=1:nifA(i)=b(i)errA=errA;elseerrA=errA+1;endifF(i)=b(i)errF=errF;elseerrF=errF+1;en
14、difP(i)=b(i)errP=errP;elseerrP=errP+1;endendBER_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(010-0.51.5);gridontitle(ReceivedsignalafterAWGNChannel)subplot(412)tb=0:1/30:10-1/30;plot(tb,askn(1:10*30),b,linewidth,1.5)title
15、(ReceivedASKsignal);gridonsubplot(413)plot(tb,fskn(1:10*30),r,linewidth,1.5)title(ReceivedFSKsignal);gridonsubplot(414)plot(tb,pskn(1:10*30),k,linewidth,1.5)title(ReceivedPSKsignal);gridonfigure(3)semilogy(0:30,BER_A,b,linewidth,2)title(BERVsSNR)gridon;holdonsemilogy(0:30,BER_F,r,linewidth,2)semilog
16、y(0:30,BER_P,k,linewidth,2)xlabel(Eo/No(dB)ylabel(BER)holdofflegend(ASK,FSK,PSK);实验四clcclear%Generationofbitpatterns=round(rand(1,25);signal=;%Generating20bitscarrier=;t=0:2*pi/119:2*pi;fork=1:25%Creating60samplesforonecosineifs(1,k)=0sig=-ones(1,120);%120minusonesforbit0%120onesforbit1elsesig=ones(
17、1,120);endc=cos(t);carrier=carrierc;signal=signalsig;endsubplot(4,1,1);plot(signal);axis(-1003100-1.51.5);title(bfitOriginalBitSequence);%BPSKModulationofthesignalbpsk_sig=signal.*carrier;subplot(4,1,2);%Modulatingthesignalplot(bpsk_sig)axis(-1003100-1.51.5);title(bfitBPSKModulatedSignal);%Preparati
18、onof6newcarrierfrequenciest1=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=c1c1c1c1c1c1c1c1c1c1c1c1;c2=cos(t2);c2=c2c2c2c2c2c2;c3=cos(t3);c3=c3c3c3c3;c4=cos(t4);c4=c4c4c4;c5=cos(t5);c5=c5c5;c6=cos(t6);%Randomfrequencyhoppstofor
19、maspreadsignalspread_signal=;forn=1:25c=randint(1,1,16);switch(c)case(1)spread_signal=spread_signalc1;case(2)spread_signal=spread_signalc2;case(3)spread_signal=spread_signalc3;case(4)spread_signal=spread_signalc4;case(5)spread_signal=spread_signalc5;case(6)spread_signal=spread_signalc6;endendsubplot
20、(4,1,3)plot(1:3000,spread_signal);axis(-1003100-1.51.5);title(bfitSpreadSignalwith6frequencies);%SpreadingBPSKSignalintowiderbandwithtotalof12frequenciesfreq_hopped_sig=bpsk_sig.*spread_signal;subplot(4,1,4)plot(1:3000,freq_hopped_sig);axis(-1003100-1.51.5);title(bfitFrequencyHoppedSpreadSpectrumSignal);%ExpressingtheFFTsfigure,subplot(2,1,1)plot(1:3000,freq_hopped_sig);axis(-1003100-1.51.5);title(bfitFrequencyHoppedSpreadSpectrumsignalanditsFFT);subplot(2,1,2);plot(1:3000,abs(fft(freq_hopped_sig);
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1