




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、實(shí)驗(yàn)內(nèi)容:利用Matlab軟件的GUI界面編程,做一個(gè)簡(jiǎn)單的界面,通過(guò)此界面調(diào)用相關(guān)的程序去實(shí)現(xiàn)由抽樣判決后的AMI碼型、CMI碼型和HDB3碼型數(shù)字序列恢復(fù)出原始的PCM脈沖編碼信號(hào)。實(shí)驗(yàn)?zāi)康模?,熟悉Matlab的GUI的編程操作,學(xué)會(huì)運(yùn)用GUI來(lái)建立一個(gè)界面2.掌握AMI,CMI,HDB3碼型的特點(diǎn)和意義,學(xué)會(huì)將PCM脈沖編碼信號(hào)轉(zhuǎn)化為AMI,CMI,HDB3的編碼以及AMI,CMI,HDB3解碼的方式。實(shí)驗(yàn)方法:實(shí)驗(yàn)中采用的方法是先建立大概的界面,其中包括輸入框、按鈕、提示內(nèi)容及坐標(biāo)系等。然后再對(duì)各種組件設(shè)置好屬性,并對(duì)各個(gè)組件編寫回調(diào)函數(shù),最后進(jìn)行調(diào)試驗(yàn)證饑渴。實(shí)驗(yàn)代碼:1. AMI
2、碼型轉(zhuǎn)換: % 編碼 %p = -1;for i=1:length(f); if f(i)=1 e(i) = (-1)*p; p = e(i); else e(i) = f(i); endend% 譯碼 %for i=1:length(f); if e(i)=0 l(i) = 1; else e(i) = 0; endend編碼:代碼中的f代表著輸入字符串轉(zhuǎn)化后的ASCII碼,用變量p來(lái)實(shí)現(xiàn)原信號(hào)中1的正負(fù)交替。例如,f(1)=1,則e(1)=1,p=1;f(2)=1,則e(2)=-1,p=-1。如此就可以得到正負(fù)1交替了。譯碼:當(dāng)e(i)不等于0,就把結(jié)果等于1。2. CMI碼型轉(zhuǎn)換 % 編
3、碼 %m=1;p=-1; for i=1:length(f) if(f(i)=1&m=1) s(i)=3; m=m*p; else if(f(i)=1&m=-1) s(i)=0; m=m*p; else s(i)=1; endend end k=dec2bin(s,2); l=k' x=l(:); y=x' n=str2num(y(1);for i=2:length(y) n=n str2num(y(i);end% 譯碼 % if n(1)=0 if n(2)=1 cm=0; else cm=1; end else cm=1; endr=3;while r<
4、;length(n) if n(r)=0 if n(r+1)=1 cm=cm 0; else cm=cm 1; end else cm=cm 1; end r=r+2;end3. HDB3碼型轉(zhuǎn)換 % 編碼 %yn=xn;% 輸出yn初始化num=0;% 計(jì)數(shù)器初始化for k=1:length(xn) if xn(k)=1 num=num+1; % "1"計(jì)數(shù)器 if num/2 = fix(num/2) % 奇數(shù)個(gè)1時(shí)輸出-1,進(jìn)行極性交替 yn(k)=1; else yn(k)=-1; end endend % HDB3編碼num=0; % 連零計(jì)數(shù)器初始化yh=yn
5、; % 輸出初始化sign=0; % 極性標(biāo)志初始化為0V=zeros(1,length(yn);% V脈沖位置記錄變量 B=zeros(1,length(yn);% B脈沖位置記錄變量for k=1:length(yn) if yn(k)=0 num=num+1; % 連“0”個(gè)數(shù)計(jì)數(shù) if num=4 % 如果4連“0” num=0; % 計(jì)數(shù)器清零 yh(k)=1*yh(k-4); % 讓0000的最后一個(gè)0改變?yōu)榕c前一個(gè)非零符號(hào)相同極性的符號(hào) V(k)=yh(k); % V脈沖位置記錄 if yh(k)=sign % 如果當(dāng)前V符號(hào)與前一個(gè)V符號(hào)的極性相同 yh(k)=-1*yh(k)
6、; % 則讓當(dāng)前V符號(hào)極性反轉(zhuǎn),以滿足V符號(hào)間相互極性反轉(zhuǎn)要求 yh(k-3)=yh(k); % 添加B符號(hào),與V符號(hào)同極性 B(k-3)=yh(k); % B脈沖位置記錄 V(k)=yh(k); % V脈沖位置記錄 yh(k+1:length(yn)=-1*yh(k+1:length(yn); % 并讓后面的非零符號(hào)從V符號(hào)開(kāi)始再交替變化 end sign=yh(k); % 記錄前一個(gè)V符號(hào)的極性 end else num=0; % 當(dāng)前輸入為“1”則連“0”計(jì)數(shù)器清零 endend % 譯碼 %input=yh; % HDB3碼輸入decode=input; % 輸出初始化sign=0;
7、% 極性標(biāo)志初始化for k=1:length(yh) if input(k) = 0 if sign=yh(k) % 如果當(dāng)前碼與前一個(gè)非零碼的極性相同 decode(k-3:k)=0 0 0 0;% 則該碼判為V碼并將*00V清零 end sign=input(k); % 極性標(biāo)志 endenddecode=abs(decode); % 整流實(shí)驗(yàn)現(xiàn)象: 總體界面:AMI:CMI:HDB3:總結(jié):1. 本次實(shí)驗(yàn)中因?yàn)閷?duì)畫方波不太熟悉,在使用stairs函數(shù)時(shí),方波圖總是在最后少了一位,后來(lái)經(jīng)查詢后才知道stairs的正確用法。2. 由于對(duì)GUI界面設(shè)置的不熟悉,很多細(xì)節(jié)都沒(méi)做到位,界面的美觀
8、有待提高。3. 在編代碼是經(jīng)常沒(méi)有寫注釋,導(dǎo)致后來(lái)有些變量混淆了。附錄:全部代碼function varargout = untitled1(varargin)% UNTITLED1 M-file for untitled1.fig% UNTITLED1, by itself, creates a new UNTITLED1 or raises the existing% singleton*.% H = UNTITLED1 returns the handle to a new UNTITLED1 or the handle to% the existing singleton*.% UNT
9、ITLED1('CALLBACK',hObject,eventData,handles,.) calls the local% function named CALLBACK in UNTITLED1.M with the given input arguments.% UNTITLED1('Property','Value',.) creates a new UNTITLED1 or raises the% existing singleton*. Starting from the left, property value pairs are
10、% applied to the GUI before untitled1_OpeningFunction gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to untitled1_OpeningFcn via varargin.% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one% instance to
11、run (singleton)".% See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help untitled1 % Last Modified by GUIDE v2.5 21-Dec-2014 19:55:20 % Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, . 'gui_Singl
12、eton', gui_Singleton, . 'gui_OpeningFcn', untitled1_OpeningFcn, . 'gui_OutputFcn', untitled1_OutputFcn, . 'gui_LayoutFcn', , . 'gui_Callback', );if nargin && ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);end if nargout varargout1:nargout =
13、 gui_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT % - Executes just before untitled1 is made visible.function untitled1_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject hand
14、le to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to untitled1 (see VARARGIN) % Choose default command line output for untitled1handles.output = hObject; % Update handles structu
15、reguidata(hObject, handles); % UIWAIT makes untitled1 wait for user response (see UIRESUME)% uiwait(handles.maxing); % - Outputs from this function are returned to the command line.function varargout = untitled1_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args
16、(see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structurevarargout1 = handles.output; function edit_Callback(hObject, eventdata, han
17、dles)% hObject handle to edit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit as text% str2double(get(hObject,'String') returns contents of
18、 edit as a double % - Executes during object creation, after setting all properties.function edit_CreateFcn(hObject, eventdata, handles)% hObject handle to edit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcn
19、s called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor') set(hObject,'BackgroundColor','white');end % - Executes on button pres
20、s in ami.function ami_Callback(hObject, eventdata, handles)user_string=get(handles.edit,'string');a=dec2bin(user_string,8);b=a'c=b(:);d=c'f=str2num(d(1);for i=2:length(d) f=f str2num(d(i);endf=f 0;% ±àÂë %p = -1;for i=1:length(f); if f(i)=1 e(i) = (-1)*p; p = e(i)
21、; else e(i) = f(i); endend% ÒëÂë %for i=1:length(f); if e(i)=0 l(i) = 1; else e(i) = 0; endendaxes(handles.axes1)t=1:length(f);stairs(t-1,f)axis(0 length(f) -2 2)xlabel('ASCIIÂë');grid minor;axes(handles.axes2)t=1:length(e);stairs(t-1,e)axis(0 length(e) -2 2)xla
22、bel('AMI ±àÂë');grid minor;axes(handles.axes3)t=1:length(l);stairs(t-1,l)axis(0 length(l) -2 2)xlabel('AMI ÒëÂë');grid minor;% hObject handle to ami (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure
23、 with handles and user data (see GUIDATA) % - Executes on button press in cmi.function cmi_Callback(hObject, eventdata, handles)user_string=get(handles.edit,'string');a=dec2bin(user_string,8);b=a'c=b(:);d=c'f=str2num(d(1);for i=2:length(d) f=f str2num(d(i);endf=f 0;% ±à
24、4;ë %m=1;p=-1; for i=1:length(f) if(f(i)=1&m=1) s(i)=3; m=m*p; else if(f(i)=1&m=-1) s(i)=0; m=m*p; else s(i)=1; endend end k=dec2bin(s,2); l=k' x=l(:); y=x' n=str2num(y(1);for i=2:length(y) n=n str2num(y(i);end% ÒëÂë % if n(1)=0 if n(2)=1 cm=0; else cm=1; end
25、 else cm=1; endr=3;while r<length(n) if n(r)=0 if n(r+1)=1 cm=cm 0; else cm=cm 1; end else cm=cm 1; end r=r+2;endaxes(handles.axes1)t=1:length(f);stairs(t-1,f)axis(0 length(f) -2 2)xlabel('ASCIIÂë');grid minor;axes(handles.axes2)t=1:length(n);stairs(t-1,n)axis(0 length(n) -2 2)x
26、label('CMI ±àÂë');grid minor;axes(handles.axes3)t=1:length(cm);stairs(t-1,cm)axis(0 length(cm) -2 2)xlabel('CMI ÒëÂë');grid minor;% hObject handle to cmi (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles stru
27、cture with handles and user data (see GUIDATA) % - Executes on button press in hdb3.function hdb3_Callback(hObject, eventdata, handles)user_string=get(handles.edit,'string');a=dec2bin(user_string,8);b=a'b=a'c=b(:);d=c'xn=str2num(d(1);for i=2:length(d) xn=xn str2num(d(i);endxn=xn
28、0;% ±àÂë %yn=xn;% Êä³öyn³õʼ»¯num=0;% ¼ÆÊýÆ÷³õʼ»¯for k=1:length(xn) if xn(k)=1 num=num+1; % "1"¼ÆÊýÆ÷ if num/2 = fix(num/2) %
29、98;æÊý¸ö1ʱÊä³ö-1,½øÐм«ÐÔ½»Ìæ yn(k)=1; else yn(k)=-1; end endend % HDB3±àÂënum=0; % Á¬Áã¼ÆÊýÆ÷³õÊ
30、188;»¯yh=yn; % Êä³ö³õʼ»¯sign=0; % ¼«ÐÔ±êÖ¾³õʼ»¯Îª0V=zeros(1,length(yn);% VÂö³åλÖüǼ±ä
31、Á¿ B=zeros(1,length(yn);% BÂö³åλÖüǼ±äÁ¿for k=1:length(yn) if yn(k)=0 num=num+1; % Á¬¡°0¡±¸öÊý¼ÆÊý if num=4 % Èç¹û4
32、193;¬¡°0¡± num=0; % ¼ÆÊýÆ÷ÇåÁã yh(k)=1*yh(k-4); % ÈÃ0000µÄ×îºóÒ»¸ö0¸Ä±äΪÓëÇ°Ò»¸ö·Ç
33、193;ã·ûºÅÏàͬ¼«ÐԵķûºÅ V(k)=yh(k); % VÂö³åλÖüǼ if yh(k)=sign % Èç¹ûµ±Ç°V·ûºÅ
34、1;ëÇ°Ò»¸öV·ûºÅµÄ¼«ÐÔÏàͬ yh(k)=-1*yh(k); % ÔòÈõ±Ç°V·ûºÅ¼«ÐÔ·´×ª,ÒÔÂú×
35、ãV·ûºÅ¼äÏ໥¼«ÐÔ·´×ªÒªÇó yh(k-3)=yh(k); % Ìí¼ÓB·ûºÅ,ÓëV·ûºÅͬ¼«ÐÔ B(k-3)=yh(k); % B
36、194;ö³åλÖüǼ V(k)=yh(k); % VÂö³åλÖüǼ yh(k+1:length(yn)=-1*yh(k+1:length(yn); % ²¢ÈúóÃæµÄ·ÇÁã·û
37、86;Å´ÓV·ûºÅ¿ªÊ¼ÔÙ½»Ìæ±ä»¯ end sign=yh(k); % ¼Ç¼ǰһ¸öV·ûºÅµÄ¼«ÐÔ end else num=0; % µ±
38、;Ç°ÊäÈëΪ¡°1¡±ÔòÁ¬¡°0¡±¼ÆÊýÆ÷ÇåÁã endend % ÒëÂë %input=yh; % HDB3ÂëÊäÈëdecode=input; % Êä&
39、#179;ö³õʼ»¯sign=0; % ¼«ÐÔ±êÖ¾³õʼ»¯for k=1:length(yh) if input(k) = 0 if sign=yh(k) % Èç¹ûµ±Ç°ÂëÓëÇ°Ò»¸ö
40、·ÇÁãÂëµÄ¼«ÐÔÏàͬ decode(k-3:k)=0 0 0 0;% Ôò¸ÃÂëÅÐΪVÂë²¢½«*00VÇåÁã end sign=input(k); % ¼«ÐÔ±êÖ¾ endenddecode=abs(decode); %
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 倉(cāng)庫(kù)信息化建設(shè)的路徑分析計(jì)劃
- 生態(tài)學(xué)學(xué)習(xí)單元計(jì)劃
- 教學(xué)工作考核標(biāo)準(zhǔn)計(jì)劃
- 質(zhì)量管理體系與產(chǎn)品質(zhì)量監(jiān)控并重策略
- 高清視覺(jué)體驗(yàn)高清視屏的快速剪接和優(yōu)化策略分享
- 山西2025年01月太原市小店區(qū)唐槐街道辦事處公開(kāi)招考15名勞務(wù)派遣制工作人員筆試歷年典型考題(歷年真題考點(diǎn))解題思路附帶答案詳解
- 2025廣西欽州市浦北縣“智匯浦北”集中招聘26人筆試參考題庫(kù)附帶答案詳解
- 跨國(guó)企業(yè)如何管理全球著作權(quán)事務(wù)
- 通過(guò)血液透析室的內(nèi)部管理提升患者體驗(yàn)
- 高中語(yǔ)文情感美文流年逝水思念成殤
- 2025年舞蹈培訓(xùn)機(jī)構(gòu)學(xué)員培訓(xùn)合同范本
- 2025年保險(xiǎn)銷售業(yè)務(wù)人員崗位職業(yè)技能資格知識(shí)考試題(附答案)
- 兒科護(hù)理模擬考試題與參考答案
- 2025年南網(wǎng)數(shù)字集團(tuán)公開(kāi)選聘高頻重點(diǎn)模擬試卷提升(共500題附帶答案詳解)
- 西門子S7-1200 PLC應(yīng)用技術(shù)項(xiàng)目教程(第3版) 考試復(fù)習(xí)題
- 2025屆高考語(yǔ)文二輪復(fù)習(xí)語(yǔ)文備考策略
- 部編版語(yǔ)文小學(xué)二年級(jí)下冊(cè)第一單元集體備課(教材解讀)
- 通信工程建設(shè)標(biāo)準(zhǔn)強(qiáng)制性條文匯編(2023版)-定額質(zhì)監(jiān)中心
- 高等傳熱學(xué)全冊(cè)課件
- (正式版)JBT 11270-2024 立體倉(cāng)庫(kù)組合式鋼結(jié)構(gòu)貨架技術(shù)規(guī)范
- 最全全國(guó)各省市縣名稱
評(píng)論
0/150
提交評(píng)論