卷积码编译码程序教学内容.doc

卷积码编译码程序教学内容.doc

ID:57090914

大小:23.50 KB

页数:6页

时间:2020-08-02

卷积码编译码程序教学内容.doc_第1页
卷积码编译码程序教学内容.doc_第2页
卷积码编译码程序教学内容.doc_第3页
卷积码编译码程序教学内容.doc_第4页
卷积码编译码程序教学内容.doc_第5页
资源描述:

《卷积码编译码程序教学内容.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、卷积码编译码程序精品文档这是我搜集整理的一个关于卷积编码和Viterbi译码的Matlab程序,现在把它们放在这里,希望对需要的人有些帮助。  卷积编码程序:function[output,len_tal]=cnv_encd(secrettext,encodetext)g=[00100100;00000001;10000001;01001101];k0=1;%读入文本文件并计算文件长度 frr=fopen(secrettext,'r'); [msg,len]=fread(frr,'ubit1'); msg=msg'; %checktoseeifextr

2、azeropaddingisnecessary ifrem(length(msg),k0)>0    msg=[msg,zeros(size(1:k0-rem(length(msg),k0)))]; endn=length(msg)/k0;         %把输入比特按k0分组,n为所得的组数。%checkthesizeofmatrixg ifrem(size(g,2),k0)>0    error('Error,gisnotoftherightsize.'); end%determineLandn0 L=size(g,2)/k0; n0=size(

3、g,1);%addextrazeros,以保证编码器是从全0开始,并回到全0状态。 u=[zeros(size(1:(L-1)*k0)),msg,zeros(size(1:(L-1)*k0))];%generateuu,amatrixwhosecolumnsarethecontentsofconv.encoderat %variousclockcycles. u1=u(L*k0:-1:1); fori=1:n+L-2    u1=[u1,u((i+L)*k0:-1:i*k0+1)]; enduu=reshape(u1,L*k0,n+L-1);收集于网络

4、,如有侵权请联系管理员删除精品文档%determinetheoutput output=reshape(rem(g*uu,2),1,n0*(L+n-1)); len_tal=n0*(L+n-1);%writetheoutputtotheencodetext result=fopen(encodetext,'w'); fori=1:n0*(L+n-1)    fwrite(result,output(i),'bit1'); endfclose(result);  Viterbi译码程序:function[decoder_output,survivor_s

5、tate,cumulated_metric]=viterbi(channel_output,decodetext) tic G=[00100100;00000001;10000001;01001101]; k=1;frr=fopen(channel_output,'r'); [msg,len]=fread(frr,'ubit1'); channel_output=msg';n=size(G,1);%checkthesizes ifrem(size(G,2),k)~=0    error('channel_outputnotoftherightsize'

6、); endL=size(G,2)/k; number_of_states=2^((L-1)*k);%generatestatetransitionmatrix,outputmatrix,andinputmatrix forj=0:number_of_states-1    fori=0:2^k-1        [next_state,memory_contents]=nxt_stat(j,i,L,k);        input(j+1,next_state+1)=i;        branch_output=rem(memory_content

7、s*G',2);        nextstate(j+1,i+1)=next_state;        output(j+1,i+1)=bin2deci(branch_output);    end end收集于网络,如有侵权请联系管理员删除精品文档%addtheextrazero,ensurethelengthofchannel_outputisintegral %timeston. ifrem(len,n)>0    channel_output=[channel_output,zeros(size(n-rem(len,n):-1:1))];

8、endstate_metric=zeros(number_of_states,2); dept

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。