MATLAB程序設(shè)計(jì)報(bào)告-基于MATLAB動(dòng)畫播放及音樂播放_(tái)第1頁
MATLAB程序設(shè)計(jì)報(bào)告-基于MATLAB動(dòng)畫播放及音樂播放_(tái)第2頁
MATLAB程序設(shè)計(jì)報(bào)告-基于MATLAB動(dòng)畫播放及音樂播放_(tái)第3頁
MATLAB程序設(shè)計(jì)報(bào)告-基于MATLAB動(dòng)畫播放及音樂播放_(tái)第4頁
MATLAB程序設(shè)計(jì)報(bào)告-基于MATLAB動(dòng)畫播放及音樂播放_(tái)第5頁
已閱讀5頁,還剩13頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

《MATLAB程序設(shè)計(jì)》課程設(shè)計(jì)報(bào)告設(shè)計(jì)題目:基于設(shè)計(jì)題目:基于MATLAB的動(dòng)畫演示及背景音樂插入2011級(jí)通信工程(學(xué)號(hào)):儲(chǔ)光雄1162310213加少林1162310214徐凱越1162310223指導(dǎo)教班倪建軍(博士/副教授)指導(dǎo)教班倪建軍(博士/副教授)時(shí)間:2013年12月20日word.可修編-可修編-可修編?可修編?目錄1、設(shè)計(jì)目的2、總體設(shè)計(jì)3、具體設(shè)計(jì)(功能實(shí)現(xiàn))4、結(jié)果分析5、改進(jìn)方向6、心得體會(huì)文獻(xiàn)的錄

1、設(shè)計(jì)目的學(xué)會(huì)運(yùn)用matlab工具箱實(shí)現(xiàn)matlabGUI設(shè)計(jì),處理動(dòng)畫運(yùn)行,以及添加背景音樂,并實(shí)現(xiàn)其動(dòng)態(tài)操作,如繼續(xù)、暫停等I力能。2、總體設(shè)計(jì)

警MenuEditor 0回一雙主要包括:動(dòng)畫模塊,音樂模塊,動(dòng)畫顯示模塊3、具體設(shè)it(功能實(shí)現(xiàn))1)動(dòng)畫模塊(1)打開動(dòng)畫文件:從文件打開對(duì)話框選擇動(dòng)畫程序,實(shí)現(xiàn)動(dòng)畫播放的可選擇性程序?qū)崿F(xiàn)代碼如下:functionbtnvopen_Callback(hObject,eventdata,handles)%hObjecthandletobtnvopen(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalvfname%動(dòng)畫文件名可修編?可修編?可修編?可修編?[vfnamevpnamevindex]=uigetfile(,*.m,,'choosemoivefile);len=length(vfname);ifvindexset(handles.txtvname,string',vfname(1:len-2))end打開對(duì)話框效果如下:■Qchoosemoivefile(2)■Qchoosemoivefile(2)開始動(dòng)國(guó)播放:先獲取文件名稱vfname(1:len-2),然后用「un()命令來執(zhí)行程序?qū)崿F(xiàn)代碼如下:functionbtnvstart_Callback(hObject,eventdata,handles)%hObjecthandletobtnvstart(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalvfnametryIen=length(vfname);run(vfname(1:len-2));catchmsgbox(sorry,therearesomeerrorwhileplayingmovie!','NOTICING');end以下是其中兩個(gè)動(dòng)畫程序snow3]i%***************設(shè)置背景*————***%A=imread('H:\YOU.jpg,);h=figure;imshow(A);axesaxis([0101]);axisoff;seUgcf/color'/k');N=20;handles=zeros(1,N);x=rand(2,N);fontsize=floor(rand(1,N)*17+32);newhandlesN=0;%繪圖fori=1:Nhandles(i)=text(x(1,i),x(2,i),,*l),fontsize,,fontsize(i),,color,),w);endwhile1if-ishandle(h)returnendfori=1:Ntemp=get(handles(i),'position,);step=get(handles(i),'fontsize,)/48*0.05;iftemp(2)<0new_handles_N=newJandles_N+1;new_handles(new_handles_N)=copyobj(handles(i),gca);ifnew_handles_N==500delete(new_handles);newhandlesN=0;endtemp(1)=rand(1);temp(2)=1;elsetemp(1)=temp(1)+rand(1)*0.1-0.05;temp(2)=temp(2)-step;endset(handles(i),position',temp,TotatiorT,Qet(handles(i)「rotation')+5);endpause(.2)end簡(jiǎn)單程序動(dòng)畫tryMovie=moviein(16);fork=1:16plot(fft(eye(k+16)))axisequalaxisoffM(k)=getframe;endmovie(M,30);catchmsgbox(sorry,therearesomeerrorwhileplayingmovie!',NOTICING');end動(dòng)值效果如下:

i-VIDEOstartImoviewordspausetest3(3)暫停/繼續(xù)功能:獲取pause按扭string參數(shù),實(shí)現(xiàn)暫停和繼續(xù)偏放功能的pausetest3切換,而通過timerPause()p數(shù)來實(shí)現(xiàn)其功能程序?qū)崿F(xiàn)代碼如下:functionbtnvpause_Callback(hObject,eventdata,handles)%hObjecthandletobtnvpause(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalsymPausetryifstrcmpfgetfhandles.btnvpause/string),'pause')handles.timerl=timerfPeriod,,0.1,'ExecutionMode1,'singleShot'/timerF,,{timerPause});set(handles.btnvpause,'string,1,continue)start(handles.timerl);elseifstrcmp(get(handles.btnvpause,'stnng),continue')symPause=0;set(handles.btnvpause,,string'1,pause)endcatchmsgbox(sorry,therearesomeerrorwhileexcutingthefunction!','NOTICING'.'error');endfunctiontimerPause(hObject,eventdata,handles)globalsymPausesymPause=1;whilesymPause==1pause(1)end(4)添加文字functionbtnvshow_Callback(hObject,eventdata,handles)%hObjecthandletobtnvshow(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)tryifgetfhandles.txtvword/string')seVhandles.stxtshow/string\getthandles.txtvword/string'),...,visible'.'on'/fontname'.g^la'.'fontsize',^.O);elseset(handles.stxtshow,'visible','off1);msgbox(Addsomewordsfirst!');endcatchmsgbox(sorry,therearesomeerrorwhileexcutingthefunction!,,NOTICING','error);end

wordshello?howisgoing?showwordshello?howisgoing?show2)音樂模塊(1)打開音樂functionbtnmbrowse_Callback(hObject,eventdata,handles)%hObjecthandletobtnmbrowse(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalmfilepathtry[mfnamempnamemindex]=uigetfile('*.wav','choosemusic);ifmindexmfilepath=[mpnamemfname];setfhandles.editl/string\mfilepath);try[data,Fs,nbits]=wavread('youareasonginmyheart.wav');catchmsgbox(sorry,thedefaultmusicdoesnotexist','NOTICING);endendplayer=audioplayer(data,Fs,nbits);play(player);sign=ture';set(handles.btnmpause,'string,pause','Enable'/on);catchmsgbox(Rrrorwhileplayingmusic!','NOTICING');end(3)暫停/繼續(xù)I力能functionbtnmpause_Callback(hObject,eventdata,handles)%hObjecthandletobtnmpause(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalplayersigntryifstrcmpfgetfhandles.btnmpause/string),'pause')pause(player);seVhandles.btnmpause/string/continue);elseifstrcmpfgeVhandles.btnmpause/string'),'continue')resume(player);seUhandles.btnmpause/string'/pause);endcatchmsgboxCsorry,therearesomeerrorwhileexcutingthefunction!','NOTICING');end(4)停止播放音樂functionbtnmstop_Callback(hObject,eventdata,handles)%hObjecthandletobtnmstop(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurev/ithhandlesanduserdata(seeGUIDATA)globalplayersigntrystop(player);sign='false';set(handles.btnmpause,stringypauseYEnableYoff');catchmsgbox('ERROR;NOTICING');end3)其他輔助功能(1)關(guān)閉程序:在退出程序時(shí),音樂不會(huì)自動(dòng)停止,所以為了在退出程序時(shí)同時(shí)關(guān)閉音樂,才加入此功能functionfigure1_DeleteF(hObject,eventdata,handles)%hObjecthandletofigurel(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalplayersigntryifstrcmpfsign/true')stop(player);closeallendcatchmsgboxfsorry,therearesomeerrorwhileexcutingthefunction!','NOTICINGVerror');end(2)異常捕捉機(jī)Mtry-catch由于程序功能再設(shè)計(jì)上考慮的并不是十分全面,可能會(huì)出現(xiàn)預(yù)料不到的錯(cuò)誤,因此加入此I力能,避免在出現(xiàn)未知錯(cuò)誤時(shí),程序崩溫。4、結(jié)果分析I力能實(shí)現(xiàn)上看,基本上能達(dá)到預(yù)期效果,各個(gè)助能均可正常執(zhí)行,在動(dòng)畫儡放方面,有些方面還不盡如人意,比如說,由于實(shí)現(xiàn)了動(dòng)畫的可切換性,也就是說動(dòng)畫程序的獨(dú)立性,使得自己編寫的m文件和程序部參數(shù)部分不一致,便得出現(xiàn)不同效果,比虬有時(shí)動(dòng)畫在設(shè)計(jì)好的GUI界面上顯示,有時(shí)義以獨(dú)立的窗口運(yùn)行。音樂模塊則與模期一致。另外,應(yīng)垓說是非人力因素,在動(dòng)畫播放的時(shí)候,添加背景音樂,此時(shí)動(dòng)畫會(huì)暫停,當(dāng)音樂開始播放時(shí),動(dòng)I■也恢復(fù)正常。U這個(gè)結(jié)果看,程序部命令會(huì)相互第響,所以這將是我們以優(yōu)化程序的一個(gè)方向??尚蘧?可修編-可修編-可修編-5、改進(jìn)方向卜程序演示過程發(fā)現(xiàn)以下問題,這將是本程序優(yōu)化的方向。(1)回調(diào)函數(shù)之間的干擾:最明顯的紿果表現(xiàn)為,動(dòng)畫運(yùn)行過程中,點(diǎn)擊其他的技鈕,將短時(shí)間暫停動(dòng)畫程序。所以如何將動(dòng)畫獨(dú)立于GUI之外,同時(shí)又受GUI界面按鉗的控制,G是界序優(yōu)化重點(diǎn)之一。(2)動(dòng)畫程序編寫模塊:雖說本程序可以實(shí)現(xiàn)

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(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ì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論