ImageVerifierCode 换一换
格式:DOCX , 页数:20 ,大小:88.54KB ,
资源ID:11765728      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/11765728.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(基于某matlab地码型转换.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

基于某matlab地码型转换.docx

1、基于某matlab地码型转换实验容:利用Matlab软件的GUI界面编程,做一个简单的界面,通过此界面调用相关的程序去实现由抽样判决后的AMI码型、CMI码型和HDB3码型数字序列恢复出原始的PCM脉冲编码信号。实验目的:1,熟悉Matlab的GUI的编程操作,学会运用GUI来建立一个界面2.掌握AMI,CMI,HDB3码型的特点和意义,学会将PCM脉冲编码信号转化为AMI,CMI,HDB3的编码以及AMI,CMI,HDB3解码的方式。实验方法:实验中采用的方法是先建立大概的界面,其中包括输入框、按钮、提示容及坐标系等。然后再对各种组件设置好属性,并对各个组件编写回调函数,最后进行调试验证饥渴

2、。实验代码:1. AMI码型转换:% 编码 %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代表着输入字符串转化后的ASCII码,用变量p来实现原信号中1的正负交替。例如,f(1)=1,则e(1)=1,p=1;f(2)=1,则e(2)=-1,p=-1。如此就可以得到正负1交替了。译码:当e(i)不等于0,就把结果等于1。2.

3、CMI码型转换 % 编码 %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 rlength(n

4、) 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码型转换 % 编码 %yn=xn;% 输出yn初始化num=0;% 计数器初始化for k=1:length(xn) if xn(k)=1 num=num+1; % 1计数器 if num/2 = fix(num/2) % 奇数个1时输出-1,进行极性交替 yn(k)=1; else yn(k)=-1; end endend % HDB3编码num=0; % 连零计数器初始化yh=yn; % 输出初始化sign=0; % 极性

5、标志初始化为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”个数计数 if num=4 % 如果4连“0” num=0; % 计数器清零 yh(k)=1*yh(k-4); % 让0000的最后一个0改变为与前一个非零符号相同极性的符号 V(k)=yh(k); % V脉冲位置记录 if yh(k)=sign % 如果当前V符号与前一个V符号的极性相同 yh(k)=-1*yh(k); % 则让当前V符号极性反转,以满足V符号

6、间相互极性反转要求 yh(k-3)=yh(k); % 添加B符号,与V符号同极性 B(k-3)=yh(k); % B脉冲位置记录 V(k)=yh(k); % V脉冲位置记录 yh(k+1:length(yn)=-1*yh(k+1:length(yn); % 并让后面的非零符号从V符号开始再交替变化 end sign=yh(k); % 记录前一个V符号的极性 end else num=0; % 当前输入为“1”则连“0”计数器清零 endend % 译码 %input=yh; % HDB3码输入decode=input; % 输出初始化sign=0; % 极性标志初始化for k=1:lengt

7、h(yh) if input(k) = 0 if sign=yh(k) % 如果当前码与前一个非零码的极性相同 decode(k-3:k)=0 0 0 0;% 则该码判为V码并将*00V清零 end sign=input(k); % 极性标志 endenddecode=abs(decode); % 整流实验现象:总体界面:AMI:CMI:HDB3:总结:1. 本次实验中因为对画方波不太熟悉,在使用stairs函数时,方波图总是在最后少了一位,后来经查询后才知道stairs的正确用法。2. 由于对GUI界面设置的不熟悉,很多细节都没做到位,界面的美观有待提高。3. 在编代码是经常没有写注释,导致

8、后来有些变量混淆了。附录:全部代码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*.% UNTITLED1(CALLBACK,hObject

9、,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% applied to the GUI before untitled1_OpeningFunction

10、 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 GUIDEs Tools menu. Choose GUI allows only one% instance to run (singleton).% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the

11、 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_Singleton, gui_Singleton, .gui_OpeningFcn, untitled1_OpeningFcn, .gui_OutputFcn, untitled1_Out

12、putFcn, .gui_LayoutFcn, , .gui_Callback, );if nargin & ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);endif nargout varargout1:nargout = gui_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT% - Executes just before untitle

13、d1 is made visible.function untitled1_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin

14、command line arguments to untitled1 (see VARARGIN)% Choose default command line output for untitled1handles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes untitled1 wait for user response (see UIRESUME)% uiwait(handles.maxing);% - Outputs from this function are r

15、eturned to the command line.function varargout = untitled1_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user dat

16、a (see GUIDATA)% Get default command line output from handles structurevarargout1 = handles.output;function edit_Callback(hObject, eventdata, handles)% hObject handle to edit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (s

17、ee GUIDATA)% Hints: get(hObject,String) returns contents of edit as text% str2double(get(hObject,String) returns contents of edit as a double% - Executes during object creation, after setting all properties.function edit_CreateFcn(hObject, eventdata, handles)% hObject handle to edit (see GCBO)% even

18、tdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackground

19、Color) set(hObject,BackgroundColor,white);end% - Executes on button press 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(

20、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;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)xlabel(AMI );grid minor;axe

21、s(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 with handles and user data (see GUIDATA)% - Executes on button press in cmi.function cmi_Ca

22、llback(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;% %m=1;p=-1;for i=1:length(f)if(f(i)=1&m=1) s(i)=3; m=m*p;elseif(f(i)=1&m=-1) s(i)=0; m=m*p;else s(i)=1;endendend k=dec2bin(s,2);

23、 l=k; x=l(:); y=x; n=str2num(y(1);for i=2:length(y) n=n str2num(y(i);end% %if n(1)=0if n(2)=1 cm=0;else cm=1;endelse cm=1;endr=3;while rlength(n)if n(r)=0if n(r+1)=1 cm=cm 0;else cm=cm 1;endelse 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);gr

24、id minor;axes(handles.axes2)t=1:length(n);stairs(t-1,n)axis(0 length(n) -2 2)xlabel(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% ha

25、ndles structure 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 0;% %yn=xn;%

26、ynnum=0;% for k=1:length(xn)if xn(k)=1 num=num+1; % 1if num/2 = fix(num/2) % 1-1, yn(k)=1;else yn(k)=-1;endendend% HDB3num=0; % yh=yn; % sign=0; % 0V=zeros(1,length(yn);% V B=zeros(1,length(yn);% Bfor k=1:length(yn)if yn(k)=0 num=num+1; % 0if num=4 % 40 num=0; % yh(k)=1*yh(k-4); % 00000 V(k)=yh(k); % Vif yh(k)=sign % VV yh(k)=-1*yh(k); % V,V yh(k-3)=yh(k); % B,V B(k-3)=yh(k); % B V(k)=yh(k); % V yh(k+1:length(yn)=-1*yh(k+1:length(yn);% Vend sign=yh(k); % Vendelse num=0; % 10endend% %input=yh; % HDB3decode=input; % sign=0; % for k=1:length(yh)if input(k) = 0if sign=yh(k) % decode(k-3:k)

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1