基于MATLAB的(7,4)循環(huán)碼的編譯仿真_第1頁
基于MATLAB的(7,4)循環(huán)碼的編譯仿真_第2頁
基于MATLAB的(7,4)循環(huán)碼的編譯仿真_第3頁
基于MATLAB的(7,4)循環(huán)碼的編譯仿真_第4頁
基于MATLAB的(7,4)循環(huán)碼的編譯仿真_第5頁
已閱讀5頁,還剩6頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

#bk—1,n—k—1bk—2,n—k—1b0,n—k—1100_H=b?b?b0?.10⑹tk—1,1brk—2,1b…,八,1b0??s?0■1-k—1,0k—2,00,0-已知(7,4)循環(huán)碼的生成多項(xiàng)式和校驗(yàn)多項(xiàng)式分別為:g(x)=x3+x+1,h(x)=X4+x2+x+1。寫得其生成矩陣和校驗(yàn)矩陣分別為:…(7)(8)循環(huán)碼的編譯碼過程如下:編碼過程第一步:將信息碼字表示為m(x),其最高次幕為k-1;第二步:將xn-km(x)與g(x)求模得出相應(yīng)的余式r(x);第三步:編碼結(jié)果為c(x)=xn-km(x)+r(x)。譯碼過程第一步:由接收碼字R(x)與監(jiān)督矩陣相乘得出錯誤圖樣S;第二步:判斷S是否為零。若不為零,則出錯。在假定至多只有一位錯的情況下,可以有效地譯了相應(yīng)的信息碼字。第三步:在出錯的情況下,將S與標(biāo)準(zhǔn)監(jiān)督矩陣對比,得出錯誤的比特位并進(jìn)行更正得出前四位為信息碼字。4、仿真結(jié)果1)編譯碼程序說明編譯碼程序由三個子函數(shù)及界面函數(shù)組成。三個子函數(shù)分別完成編碼、譯碼及字符提取的工作,以下為三個函數(shù)的源碼:%%%%%%%%cyle_code.mfunction[msg_en]=cycle_code(m,msg)%循環(huán)碼編碼函數(shù)%輸入?yún)?shù)%m:監(jiān)督位的位數(shù);%msg:信息碼字%輸出參數(shù)%msg_en:編碼結(jié)果%inputparameters%碼長與信息碼字n=2"m-l;k=n-m;%產(chǎn)生生成矩陣parmat和校驗(yàn)矩陣genmatpol=cyclpoly(n,k);[parmat,genmat,k]=cyclgen(7,pol);%調(diào)整生成矩陣與監(jiān)督矩陣gen_temp=eye(k);par_temp=eye(m);parmat=[par_tempgenmat(:,1:m)'];genmat=[gen_tempgenmat(:,1:m)];%產(chǎn)生編碼后的碼字空間Cmsg_en=rem(msg*genmat,2);%%%%%%%%cyle_decode.m%循環(huán)碼譯碼函數(shù)functioncode=cycle_decode(m,msg)%循環(huán)碼譯碼函數(shù)%輸入?yún)?shù)%m:監(jiān)督位的位數(shù);%msg:信息碼字%輸出參數(shù)%code:譯碼結(jié)果%碼長與信息碼字n=2"m-l;k=n-m;%產(chǎn)生生成矩陣parmat和校驗(yàn)矩陣genmatpol=cyclpoly(n,k);[parmat,genmat,k]=cyclgen(7,pol);%調(diào)整生成矩陣與監(jiān)督矩陣gen_temp=eye(k);par_temp=eye(m);parmat=[par_tempgenmat(:,1:m)'];genmat=[gen_tempgenmat(:,1:m)];%計(jì)算伴隨式S=rem(msg*parmat',2)';count=0;%比較譯碼if(sum(S)~=0)for(ii=1:1:n)for(jj=1:1:m)if(S(jj)==parmat(jj,ii))count=count+1;end;end;if(count==3)mis=ii;elsecount=0;end;end;elsemis=0;end;if(mis)msg(mis)=rem(msg(mis)+1,2);end;%譯碼結(jié)果code=msg(1:k);%%%%%%%%extracts_bits.mfunctionmsg=extract_bits(inf_msg)%比特提取函數(shù)%輸入?yún)?shù)%inf_msg:信息碼字%輸出參數(shù)%msg:提取結(jié)果warningofflen=length(inf_msg);msg=zeros(1,len);forii=1:lenmsg(1,ii)=str2num(inf_msg(ii));%將字符轉(zhuǎn)換成數(shù)字end;%msg%%%%%%%cycle.mfunctionvarargout=cycle(varargin)%CYCLEMATLABcodeforcycle.fig%CYCLE,byitself,createsanewCYCLEorraisestheexisting%singleton*.%%H=CYCLEreturnsthehandletoanewCYCLEorthehandleto%theexistingsingleton*.%%CYCLE('CALLBACK',hObject,eventData,handles,...)callsthelocal%functionnamedCALLBACKinCYCLE.Mwiththegiveninputarguments.%%CYCLE('Property','Value',...)createsanewCYCLEorraisesthe%existingsingleton*.Startingfromtheleft,propertyvaluepairsare%appliedtotheGUIbeforecycle_OpeningFcngetscalled.An%unrecognizedpropertynameorinvalidvaluemakespropertyapplication%stop.Allinputsarepassedtocycle_OpeningFcnviavarargin.%%*SeeGUIOptionsonGUIDE'sToolsmenu.Choose"GUIallowsonlyone%instancetorun(singleton)".%%Seealso:GUIDE,GUIDATA,GUIHANDLES%Edittheabovetexttomodifytheresponsetohelpcycle%LastModifiedbyGUIDEv2.530-Nov-201321:58:46%Begininitializationcode-DONOTEDITgui_Singleton=1;gui_State=struct('gui_Name',mfilename,...'gui_Singleton',gui_Singleton,...'gui_OpeningFcn',@cycle_OpeningFcn,...'gui_OutputFcn',@cycle_OutputFcn,...'gui_LayoutFcn',[],...'gui_Callback',[]);ifnargin&&ischar(varargin{1})gui_State.gui_Callback=str2func(varargin{1});endifnargout[varargout{1:nargout}]=gui_mainfcn(gui_State,varargin{:});elsegui_mainfcn(gui_State,varargin{:});end%Endinitializationcode-DONOTEDIT%Executesjustbeforecycleismadevisible.functioncycle_OpeningFcn(hObject,eventdata,handles,varargin)%Thisfunctionhasnooutputargs,seeOutputFcn.%hObjecthandletofigure%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%varargincommandlineargumentstocycle(seeVARARGIN)handles.output_code=hObject;handles.m=3;handles.n=2“(handles.m)-l;handles.k=handles.n-handles.m;handles.input_msg=[0000];handles.output_msg=[0000];handles.output_encode=[0000000];handles.output_decode=[0000000];put_decode=[0000000];handles.flag=0;guidata(hObject,handles);%Choosedefaultcommandlineoutputforcyclehandles.output=hObject;%Updatehandlesstructureguidata(hObject,handles);%UIWAITmakescyclewaitforuserresponse(seeUIRESUME)%uiwait(handles.figure1);%Outputsfromthisfunctionarereturnedtothecommandline.functionvarargout=cycle_OutputFcn(hObject,eventdata,handles)%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);%hObjecthandletofigure%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Getdefaultcommandlineoutputfromhandlesstructurevarargout{1}=handles.output;%Executesonbuttonpressinencode.functionencode_Callback(hObject,eventdata,handles)%hObjecthandletoencode(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)handles.code=extract_bits(handles.codes);%guidata(hObject,handles);handles.encode=cycle_code(handles.m,handles.code)handles.flag=0;str=num2str(handles.encode);set(handles.outcode,'string',str);guidata(hObject,handles);%Executesonbuttonpressindecode.functiondecode_Callback(hObject,eventdata,handles)%hObjecthandletodecode(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)handles.input_decode=extract_bits(handles.codes);guidata(hObject,handles);handles.decode=cycle_decode(handles.m,handles.input_decode);handles.flag=1;str=num2str(handles.decode);set(handles.outcode,'string',str);guidata(hObject,handles);functioninputcode_Callback(hObject,eventdata,handles)%hObjecthandletoinputcode(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)handles.codes=get(hObject,'String');guidata(hObject,handles);%Hints:get(hObject,'String')returnscontentsofinputcodeastext%str2double(get(hObject,'String'))returnscontentsofinputcodeasadouble%Executesduringobjectcreation,aftersettingallproperties.functioninputcode_CreateFcn(hObject,eventdata,handles)%hObjecthandletoinputcode(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&&isequal(get(hOb

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論