MATLAB程序设计报告--基于MATLAB动画播放及音乐播放[技术学习].doc
《MATLAB程序设计报告--基于MATLAB动画播放及音乐播放[技术学习].doc》由会员分享,可在线阅读,更多相关《MATLAB程序设计报告--基于MATLAB动画播放及音乐播放[技术学习].doc(13页珍藏版)》请在三一文库上搜索。
1、MATLAB程序设计课程设计报告设 计 题 目: 基于MATLAB的动画演示 及背景音乐插入 专 业: 2011级通信工程 姓名(学号): 储兆雄 1162310213 邓少林 1162310214 徐凯越 1162310223 指 导 教 师: 倪建军(博士/副教授)时 间: 2013年12月20日 目录1、设计目的2、总体设计3、具体设计(功能实现)4、结果分析5、改进方向6、心得体会文献附录1、设计目的学会运用matlab工具箱实现matlab GUI设计,处理动画运行,以及添加背景音乐,并实现其动态操作,如继续、暂停等功能。2、总体设计主要包括:动画模块,音乐模块,动画显示模块3、具体
2、设计(功能实现)1) 动画模块(1)打开动画文件:从文件打开对话框选择动画程序,实现动画播放的可选择性程序实现代码如下:function btnvopen_Callback(hObject, eventdata, handles)% hObject handle to btnvopen (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global vfname %动画文件名
3、vfname vpname vindex=uigetfile(*.m,choose moive file);len=length(vfname);if vindex set(handles.txtvname,string,vfname(1:len-2)end打开对话框效果如下:(2)开始动画播放:先获取文件名称vfname(1:len-2),然后用run()命令来执行程序实现代码如下:function btnvstart_Callback(hObject, eventdata, handles)% hObject handle to btnvstart (see GCBO)% eventdat
4、a reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global vfnametry len=length(vfname); run(vfname(1:len-2);catch msgbox(sorry, there are some error while playing movie!,NOTICING);end以下是其中两个动画程序snow动画%*设置背景*%A=imread(H:YOU.jpg);h=figur
5、e;imshow(A); axes axis(0 1 0 1);axis off;set(gcf,color,k); N=20; handles=zeros(1,N);x=rand(2,N);fontsize=floor(rand(1,N)*17+32); new_handles_N=0;%绘图for i=1:N handles(i)=text(x(1,i),x(2,i),*,fontsize,fontsize(i),color,w); endwhile 1 if ishandle(h) return end for i=1:N temp=get(handles(i),position); s
6、tep=get(handles(i),fontsize)/48*0.05; if temp(2)0 new_handles_N=new_handles_N+1; new_handles(new_handles_N)= copyobj(handles(i),gca); if new_handles_N=500 delete(new_handles); new_handles_N=0; end temp(1)=rand(1); temp(2)=1; else temp(1)=temp(1)+rand(1)*0.1-0.05; temp(2)=temp(2)-step; end set(handle
7、s(i),position,temp,rotation,get(handles(i),rotation)+5); end pause(.2)end简单程序动画try Movie=moviein(16); for k=1:16 plot(fft(eye(k+16) axis equal axis off M(k)=getframe; end movie(M,30);catch msgbox(sorry, there are some error while playing movie!,NOTICING);end动画效果如下:(3)暂停/继续功能:获取pause按钮string参数,实现暂停和继
8、续播放功能的切换,而通过timerPause()函数来实现其功能程序实现代码如下:function btnvpause_Callback(hObject, eventdata, handles)% hObject handle to btnvpause (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global symPausetry if strcmp(get(hand
9、les.btnvpause,string),pause) handles.timer1 = timer(Period, 0.1, ExecutionMode, singleShot,timerFcn, timerPause); set(handles.btnvpause,string,continue) start(handles.timer1); elseif strcmp(get(handles.btnvpause,string),continue) symPause =0; set(handles.btnvpause,string,pause) endcatch msgbox(sorry
10、, there are some error while excuting the function!,NOTICING,error);endfunction timerPause(hObject,eventdata,handles)global symPausesymPause=1;while symPause=1 pause(1)end(4)添加文字function btnvshow_Callback(hObject, eventdata, handles)% hObject handle to btnvshow (see GCBO)% eventdata reserved - to be
11、 defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)try if get(handles.txtvword,string) set(handles.stxtshow,string,get(handles.txtvword,string),. visible,on,fontname,fontsize,12.0); else set(handles.stxtshow,visible,off); msgbox(Add some words first!);
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 技术学习 MATLAB 程序设计 报告 基于 动画 播放 音乐 技术 学习
链接地址:https://www.31doc.com/p-9414129.html