




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、一題目請用Matlab編寫程序,繪制一個(gè)時(shí)鐘表盤和時(shí)針、分針、秒針,且時(shí)鐘能根據(jù)計(jì)算機(jī)系統(tǒng)當(dāng)前時(shí)間,自動更新時(shí)針、分針、秒針的位置。表盤和時(shí)針、分針、秒針使用plot函數(shù)繪制,計(jì)算機(jī)系統(tǒng)當(dāng)前時(shí)間使用clock函數(shù)獲取。二操作方法與實(shí)驗(yàn)步驟(1) 總體設(shè)計(jì)思想 設(shè)計(jì)時(shí)鐘,根據(jù)適中的樣式先畫出表盤,根據(jù)數(shù)學(xué)公式畫出時(shí)分刻度以及時(shí)針分針,再根據(jù)clock函數(shù)讀取計(jì)算機(jī)當(dāng)前時(shí)間,最后加上循環(huán)語句讓時(shí)鐘走起來。(2) 所用到的數(shù)學(xué)公式1. 繪制表盤(圓):x = cos (theta1); y = sin (theta1);2. 繪制時(shí)分刻度: Plot ( 0.9*cos (theta3(i) ),
2、0.97*cos(theta3(i) ) ,0.9*sin (theta3(i) ),0.97*sin( theta3(i) ) );3. 繪制時(shí)針分針:theta_h=0.5 * pi-(h+m/60)/12*2*pi;plot ( 0,0.6 * cos(theta_h), 0,0.6*sin(theta_h), 'blue','linewidth', 2);theta_m=0.5*pi-m/60*2*pi;plot (0,0.7*cos(theta_m),0,0.7*sin(theta_m), 'cyan', 'linewidth&
3、#39;, 2);theta_s=0.5*pi-(s/60)*2*pi;plot (0,0.85*cos(theta_s),0,0.85*sin(theta_s), 'black', 'linewidth', 2)4. clock讀取計(jì)算機(jī)當(dāng)前時(shí)間: C=clock; h=C(4); m=C(5); s=C(6);(3) 程序流程圖開始 用極坐標(biāo)與直角坐標(biāo)的關(guān)系繪制圓盤:theta1=0:2*pi/100:2*pi; x=cos(theta1); y=sin(theta1); h=plot(x,y);i=1;j=1;i <=12 N Y 繪制時(shí)刻度線:pl
4、ot(0.8*cos(theta2(i),0.97*cos(theta2(i),0.8*sin(theta2(i),0.97*sin(theta2(i);i +j <=12 Y繪制分刻度線:plot(0.9*cos(theta3(i),0.97*cos(theta3(i),0.9*sin(theta3(i),0.97*sin(theta3(i); set(h,'color','black');j +讀取計(jì)算機(jī)當(dāng)前時(shí)間并畫出時(shí)分秒針: C=clock; h=C(4); m=C(5); s=C(6); theta_h=0.5*pi-(h+m/60)/12*2*
5、pi;plot(0,0.6*cos(theta_h),0,0.6*sin(theta_h),'blue','linewidth',2); theta_m=0.5*pi-m/60*2*pi;plot(0,0.7*cos(theta_m),0,0.7*sin(theta_m),'cyan','linewidth',2); theta_s=0.5*pi-(s/60)*2*pi; plot(0,0.85*cos(theta_s),0,0.85*sin(theta_s),'black','linewidth'
6、,2);加上循環(huán)使表走起來:while(1)結(jié)束(4) 實(shí)驗(yàn)代碼1. 利用極坐標(biāo)與直角坐標(biāo)的關(guān)系繪制圓。 theta1=0:2*pi/100:2*pi; x=cos(theta1); y=sin(theta1); h=plot(x,y); % 繪制圓 set(h,'linewidth',6) % 設(shè)置圓的屬性 hold on % 保留已經(jīng)繪制的圖形 axis equal % 是橫縱坐標(biāo)系的單位長度相同 2. 繪制時(shí)刻度線與分刻度線 theta2=0:2*pi/12:2*pi; for i=1:length(theta2) % 循環(huán)語句繪制時(shí)刻度線h=plot(0.8*cos(t
7、heta2(i),0.97*cos(theta2(i),0.8*sin(theta2(i),0.97*sin(theta2(i); set(h,'linewidth',3) set(h,'color','black') end theta3=0:2*pi/60:2*pi; for i=1:length(theta3) % 循環(huán)語句繪制分刻度線 h=plot(0.9*cos(theta3(i),0.97*cos(theta3(i),0.9*sin(theta3(i),0.9 7*sin(theta3(i); set(h,'color'
8、;,'black') end 3. 繪制時(shí)針分針并讀取計(jì)算機(jī)當(dāng)前時(shí)間C=clock; % 調(diào)用clock函數(shù)讀取當(dāng)前時(shí)間h=C(4); % clock函數(shù):year month day hour minute seconds 4,5,6分別代表m=C(5); 時(shí)分秒s=C(6);theta_h=0.5*pi-(h+m/60)/12*2*pi;plot(0,0.6*cos(theta_h),0,0.6*sin(theta_h),'blue','linewidth',2);theta_m=0.5*pi-m/60*2*pi;plot(0,0.7*cos
9、(theta_m),0,0.7*sin(theta_m),'cyan','linewidth',2);theta_s=0.5*pi-(s/60)*2*pi;plot(0,0.85*cos(theta_s),0,0.85*sin(theta_s),'black','linewidth',2); 4. 讓時(shí)鐘走起來完成實(shí)驗(yàn) while(1) theta1=0:2*pi/100:2*pi; X=cos(theta1); y=sin(theta1); h=plot(x,y); set(h,'linewidth',6) ho
10、ld on axis equal plot(0,0,'.','Markersize',50); theta2=0:2*pi/12:2*pi; for i=1:length(theta2) h=plot(0.8*cos(theta2(i),0.97*cos(theta2(i),0.8*sin(theta2(i),0.97*sin(theta2(i); set(h,'linewidth',3) set(h,'color','black') end theta3=0:2*pi/60:2*pi; for i=1:lengt
11、h(theta3) h=plot(0.9*cos(theta3(i),0.97*cos(theta3(i),0.9*sin(theta3(i),0.97*sin(theta3(i); set(h,'color','black') end C=clock; h=C(4); m=C(5); s=C(6); theta_h=0.5*pi-(h+m/60)/12*2*pi; plot(0,0.6*cos(theta_h),0,0.6*sin(theta_h),'blue','linewidth',2); theta_m=0.5*pi-m/60*2*pi; plot(0,0.7*cos(theta_m),0,0.7*sin(theta_m),'cyan','linewidth',2); theta_s=0.5*pi-(s/
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025至2030中國外底拋光機(jī)行業(yè)發(fā)展趨勢分析與未來投資戰(zhàn)略咨詢研究報(bào)告
- 2025至2030中國臺式獸醫(yī)血液學(xué)分析儀行業(yè)市場占有率及投資前景評估規(guī)劃報(bào)告
- 2025至2030中國醫(yī)藥制劑行業(yè)市場深度研究與戰(zhàn)略咨詢分析報(bào)告
- 2025至2030中國制盒機(jī)行業(yè)產(chǎn)業(yè)運(yùn)行態(tài)勢及投資規(guī)劃深度研究報(bào)告
- 紹興新昌縣教體系統(tǒng)招聘教師筆試真題2024
- 2024年廣東開放大學(xué)輔導(dǎo)員考試真題
- 交通事故責(zé)任認(rèn)定催告函范本及處理建議
- 車位物業(yè)服務(wù)與停車場租賃管理合同
- 集裝箱車庫抵押借款服務(wù)協(xié)議
- 綠色食品加工廠場地租賃合同模板
- JG/T 3033-1996試驗(yàn)用砂漿攪拌機(jī)
- 2025年數(shù)字媒體藝術(shù)專業(yè)考試試卷及答案
- (高清版)DB13∕T 5834-2023 化工建設(shè)項(xiàng)目安裝工程質(zhì)量技術(shù)資料管理規(guī)范
- 2024 - 2025湘美版小學(xué)美術(shù)期末試卷附答案
- 安徽省蕪湖市2025屆高考二模地理試題(含答案)
- 2025年電子信息工程專業(yè)綜合能力考試卷及答案
- 2025年度6深圳中考數(shù)學(xué)考點(diǎn)、知識點(diǎn)的總結(jié)模版
- DB13(J)-T 8422-2021 建筑工程消能減震技術(shù)標(biāo)準(zhǔn)
- 2024統(tǒng)編版七年級歷史下冊 第18課《清朝的邊疆治理》教學(xué)設(shè)計(jì)
- 噴粉技術(shù)員試題及答案
- 2025銀川市輔警考試試卷真題
評論
0/150
提交評論