MATLAB(2-1-3)卷积与维特比解码代码

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

卷积编码functionoutput=convolutionX(X)%UNTITLEDSummaryofthisfunctiongoeshere%Detailedexplanationgoesheren=length(X);n1=0.01:0.01:n;for(i=1:n)is((i-1)*100+1:i*100)=X(i);endfiguresubplot(2,1,1)plot(n1,is);axis([0,n+1,-0.1,1.1]);title('原始信号')gridY=[000];%output(1)=mod(sum(Y),2);%output(2)=mod((Y(1)+Y(3)),2);for(i=1:n)Y(1)=Y(2);Y(2)=Y(3);Y(3)=X(i);Y;output(2*(i-1)+1)=mod(sum(Y),2);output(2*(i-1)+2)=mod((Y(1)+Y(3)),2);end%output(2*n+3)=X(n);%output(2*n+4)=X(n);%output(2*n+5)=0;%output(2*n+6)=0;output;a=length(output);a;t=0.01:0.01:a;for(i=1:a)st(((i-1)*100+1):i*100)=output(i);endst;subplot(2,1,2)plot(t,st);axis([0,a+1,-0.1,1.1]);title('卷积波形')gridEnd汉明距的计算functionx=distance(a,b)%UNTITLEDSummaryofthisfunctiongoeshere%Detailedexplanationgoesheren=length(a);x=0;for(i=1:n)if(a(i)~=b(i))x=x+1;elsex=x;endendend卷积编码(不显示波形)functionx=encoding(X)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%卷积编码%%%%%%%%%%%%%%%%%%%%%%%%%%%%%UNTITLED2Summaryofthisfunctiongoeshere%Detailedexplanationgoesheren=length(X);Y=[000];for(i=1:n)Y(1)=Y(2);Y(2)=Y(3);Y(3)=X(i);Y;x(2*(i-1)+1)=mod(sum(Y),2);x(2*(i-1)+2)=mod((Y(1)+Y(3)),2);endx;end解卷积(维特比解码)functionZ=deconvolution(X)%UNTITLEDSummaryofthisfunctiongoeshere%Detailedexplanationgoesheren=length(X);Z=zeros(1,n);a=n/2;M=zeros(2^a,a);Y=zeros(2^a,n);for(i=1:2^a)M(i,:)=de2bi(i-1,a);Y(i,:)=encoding(M(i,:));m(i)=distance(Y(i,:),X);endb=min(m);b;for(i=1:2^a)if(b==m(i))Z=de2bi(i-1,a);endendt=0.01:0.01:a;st=zeros(1,100*a);for(i=1:a)st(((i-1)*100+1):i*100)=Z(i);endZ;figure%subplot(2,1,2)plot(t,st);axis([0,a+1,-0.1,1.1]);title('解卷积波形')gridend

1 / 3
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功