版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 基于Matlab GUI的数字实验信号平台的设计学 校:太原工业学院班级学号: 122022328 姓 名: 马 越 1. 实现步骤:第一步(主界面): 主界面主要代码:1.进入程序加载图片:function untitledmain_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
2、 of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to untitledmain (see VARARGIN)% Choose default command line output for untitledmainhandles.output = hObject; guidata(hObject, handles);A = imread('D:DocumentsMATLABbackground.jpg');axes(ha
3、ndles.axes3);imshow(A);B = imread('D:DocumentsMATLABhydrangeas.jpg');axes(handles.axes5);imshow(B);2.pushbutton1按钮进入“基本离散信号及计算”界面function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MAT
4、LAB% handles structure with handles and user data (see GUIDATA)close;untitledjisuan;3. pushbutton2按钮进入”matlab在dft中的应用”界面function pushbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles stru
5、cture with handles and user data (see GUIDATA)close;dft;4.pushbutton3按钮进入“离散时间系统的零极点分析”界面function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user dat
6、a (see GUIDATA)close;zerosjidian;5.pushbutton4按钮用于播放背景音乐function pushbutton4_Callback(hObject, eventdata, handles)% hObject handle to pushbutton4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global player%for
7、i=1:1:100Y,Fs,nBits = wavread('yiruma ÁåÉù.wav');player=audioplayer(Y,Fs,nBits);for j=1:1:100i=isplaying(player); if i=0 play(player); endend%end6.pushbutton5用于实现音乐的暂停/继续播放功能function pushbutton5_Callback(hObject, eventdata, handles)% hObject handle to pushbutton5 (see GCB
8、O)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global playery=count();if mod(y,2)=0 pause(player);else resume(player);end第二步(主子界面):1) 基本离散信号及计算-界面主要代码如下:1.listbox1用于列出选项清单% - Executes on selection change in listbox1.fun
9、ction listbox1_Callback(hObject, eventdata, handles)% hObject handle to listbox1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: contents = cellstr(get(hObject,'String') returns listbox1 content
10、s as cell array% contentsget(hObject,'Value') returns selected item from listbox1n = get(hObject,'value');switch n case 1 close; sinxulie; case 2 close; shizhishuxulie; case 3 close; fuzhishuxulie; case 4 close; danweichongji; case 5 close; danweijieyue; case 6 close; boxingbianhuan;
11、end2) “matlab在dft中的应用”界面主要代码如下:1.按此按钮可以生成三角序列function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)a=0;n=str2num(get(handles.edi
12、t1,'string');x=zeros(size(n);for i=1:round(max(n)/2) x(i)=a; a=a+1;endfor j=round(max(n)/2)+1:max(n) x(j)=a; a=a-1;endaxes(handles.axes1);stem(n,x,'fill');2.按此按钮生成对应三角序列的dft图像function pushbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventda
13、ta reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)a=0;n=str2num(get(handles.edit1,'string');for u=1:round(max(n)/2) x(u)=a; a=a+1;endfor u=round(max(n)/2)+1:max(n) x(u)=a; a=a-1;end M=str2num(get(handles.edit2,'string'
14、;);U=fft(x,M);n1=0:1:M-1;axes(handles.axes2);stem(n1,abs(U),'fill');3.按此按钮对dft图像进行抽取function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user
15、data (see GUIDATA)a=0;n=str2num(get(handles.edit1,'string');for u=1:round(max(n)/2) x(u)=a; a=a+1;endfor u=round(max(n)/2)+1:max(n) x(u)=a; a=a-1;endM=str2num(get(handles.edit3,'string');U=fft(x,M);for i=1:2:M-1 Q(round(i/2)=U(i);endn1=0:1:round(M-2)/2);axes(handles.axes3);stem(n1,ab
16、s(Q),'fill');4.按此按钮对相应三角序列进行周期延拓function pushbutton4_Callback(hObject, eventdata, handles)% hObject handle to pushbutton4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)a=0;n=str2num(get(handles.edit1,
17、39;string');for u=1:round(max(n)/2) x(u)=a; a=a+1;endfor u=round(max(n)/2)+1:max(n) x(u)=a; a=a-1;endfor u=max(n)+1:1000 x(u)=0;end%x1=x(1:1:size(n),zeros(1,100); m=str2num(get(handles.edit4,'string');if m<max(n) xc=x(mod(n,m)+1); c=n;else n1=0:1:max(n)+100; xc=x(mod(n1,m)+1); c=n1;en
18、daxes(handles.axes4);stem(c,xc,'fill');3) “离散时间系统的零极点分析”界面第三步(次子界面的实现):注:次子界面为“基本离散信号及计算“的子界面1) 正弦序列主要代码:此按钮绘制“正弦序列“图像function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handle
19、s structure with handles and user data (see GUIDATA)n=0:40;x=cos(0.2*pi*n+pi/2);axes(handles.axes1);stem(n,x);2) 实指数序列主要代码:1.此按钮用于生成a=5/4时的实指数序列function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version
20、 of MATLAB% handles structure with handles and user data (see GUIDATA)n=0:20;a=5/4;x=a.n;%subplot(2,2,1);axes(handles.axes6);stem(n,x,'filled'); 2. 此按钮用于生成a=-5/4时的实指数序列% - Executes on button press in pushbutton4.function pushbutton4_Callback(hObject, eventdata, handles)% hObject handle to pu
21、shbutton4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)n=0:20;a=-5/4;x=a.n;%subplot(2,2,3);axes(handles.axes8);stem(n,x,'filled'); 3. 此按钮用于生成a=3/4时的实指数序列% - Executes on button press in pushbutton5.func
22、tion pushbutton5_Callback(hObject, eventdata, handles)% hObject handle to pushbutton5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)n=0:20;a=3/4;x=a.n;%subplot(2,2,2);axes(handles.axes7);stem(n,x,'filled
23、9;); 4. 此按钮用于生成a=-3/4时的实指数序列% - Executes on button press in pushbutton6.function pushbutton6_Callback(hObject, eventdata, handles)% hObject handle to pushbutton6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)n=
24、0:20;a=-3/4;x=a.n;%subplot(2,2,4);axes(handles.axes9);stem(n,x,'filled');3) 复指数序列(r>1)主要代码:此按钮用于生成r>1的复指数序列function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles str
25、ucture with handles and user data (see GUIDATA)n=0:20;r=1.2;w=pi/4;x=(r*exp(i*w).n;%subplot(2,2,1);axes(handles.axes1);stem(n,real(x),'filled');%subplot(2,2,2);axes(handles.axes2);stem(n,imag(x),'filled');%subplot(2,2,3);axes(handles.axes3);stem(n,abs(x),'filled');%subplot(2,
26、2,4);axes(handles.axes4);stem(n,(180/pi)*angle(x),'filled'); 复指数序列(r=1)主要代码:此按钮用于生成r=1的复指数序列function pushbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles a
27、nd user data (see GUIDATA)n=0:20;r=1;w=pi/4;x=(r*exp(i*w).n;%subplot(2,2,1);axes(handles.axes1);stem(n,real(x),'filled');%subplot(2,2,2);axes(handles.axes2);stem(n,imag(x),'filled');%subplot(2,2,3);axes(handles.axes3);stem(n,abs(x),'filled');%subplot(2,2,4);axes(handles.axes4
28、);stem(n,(180/pi)*angle(x),'filled'); 复指数序列(0<r<1)主要代码:此按钮用于生成0<r<1的复指数序列function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user
29、 data (see GUIDATA)n=0:20;r=0.9;w=pi/4;x=(r*exp(i*w).n;%subplot(2,2,1);axes(handles.axes1);stem(n,real(x),'filled');%subplot(2,2,2);axes(handles.axes2);stem(n,imag(x),'filled');%subplot(2,2,3);axes(handles.axes3);stem(n,abs(x),'filled');%subplot(2,2,4);axes(handles.axes4);ste
30、m(n,(180/pi)*angle(x),'filled');4) 单位冲击序列主要代码:此按钮生成”单位冲击序列”function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)k=-10:1
31、0;n=length(k);x=zeros(1,n);x(1,11)=1;axes(handles.axes1);stem(k,x,'filled');5) 单位阶跃序列主要代码:此按钮生成“单位阶跃序列”function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure wit
32、h handles and user data (see GUIDATA)k=-10:-1;kk=0:10;n=length(k);nn=length(kk);u=zeros(1,n);uu=ones(1,nn);axes(handles.axes1);stem(kk,uu,'filled');hold on;stem(k,u,'filled');6)f1x+f2x(序列相加),f1x*f2x(序列相乘)主要代码:1.此按钮生成序列f1xfunction pushbutton1_Callback(hObject, eventdata, handles)% hOb
33、ject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)n1=str2num(get(handles.edit2,'string');x1=cos(0.2*pi*n1+pi/2);axes(handles.axes3);stem(n1,x1,'filled');title('f1x'
34、;); 2.此按钮生成f1x+f2x图像% - Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)n1=str2num
35、(get(handles.edit2,'string');x1=cos(0.2*pi*n1+pi/2);n2=str2num(get(handles.edit4,'string');p=length(n2);x2=zeros(1,p);x2(1,6)=1;y3,n=sigadd(x1,n1,x2,n2);axes(handles.axes5); stem(n,y3,'filled');title('f1k+f2k'); 3.此按钮生成序列f2x% - Executes on button press in pushbutton3.
36、function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)n2=str2num(get(handles.edit4,'string');p=length(n2);x2=zeros(1,p);
37、x2(1,6)=1; axes(handles.axes4);stem(n2,x2,'filled');title('f2x');4.此按钮生成f1x*f2xfunction pushbutton6_Callback(hObject, eventdata, handles)% hObject handle to pushbutton6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and us
38、er data (see GUIDATA)n1=str2num(get(handles.edit2,'string');x1=cos(0.2*pi*n1+pi/2);n2=str2num(get(handles.edit4,'string');p=length(n2);x2=zeros(1,p);x2(1,6)=1;y3,n=sigcheng(x1,n1,x2,n2);axes(handles.axes6);stem(n,y3,'filled');title('f1k*f2k'); f1x-3,f2x-3(序列时移)主要代码:此按钮生成f1x-3,f2x-3的图像function pushbutton7_Callback(hObject, eventdata, handles)% hObject handle to pushbutton7 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles st
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 融资合同2024年度可转债发行与购买协议
- 统编人教版六年级语文上册第1课《草原》精美课件
- 游乐场装修项目合同书
- 简单解约合同协议书范本
- 租赁2024年度标准厂房合同
- 家庭内部财产分割协议书
- 工程机械租赁合同
- 健康管理学 教育课件
- 屋面防水维修工程施工合同范本
- 《防火防爆措施》课件
- GB/T 44830-2024酶联免疫试剂盒检测通则
- 责任险发展空间
- 2024年国企考试全国招考每日(5.10)管理单位遴选500模拟题附带答案详解
- 中华人民共和国保守国家秘密法实施条例
- 1.2坚持两个毫不动摇课件高中政治统编版必修二经济与社会
- 10以内连加连减练习题(直接打印版)
- 机房网络改造升级方案
- 《HSK标准教程1》第1课课件20240328
- 2024秋期国家开放大学《高层建筑施工》一平台在线形考(形考作业1至3)试题及答案
- 校园消防安全宣传教育课件
- LOPA分析报告(样本)
评论
0/150
提交评论