




版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、一題目請(qǐng)用Matlab編寫(xiě)程序,繪制一個(gè)時(shí)鐘表盤(pán)和時(shí)針、分針、秒針,且時(shí)鐘能根據(jù)計(jì)算機(jī)系統(tǒng)當(dāng)前時(shí)間,自動(dòng)更新時(shí)針、分針、秒針的位置。表盤(pán)和時(shí)針、分針、秒針使用plot函數(shù)繪制,計(jì)算機(jī)系統(tǒng)當(dāng)前時(shí)間使用clock函數(shù)獲取。二操作方法與實(shí)驗(yàn)步驟(1) 總體設(shè)計(jì)思想 設(shè)計(jì)時(shí)鐘,根據(jù)適中的樣式先畫(huà)出表盤(pán),根據(jù)數(shù)學(xué)公式畫(huà)出時(shí)分刻度以及時(shí)針?lè)轴槪俑鶕?jù)clock函數(shù)讀取計(jì)算機(jī)當(dāng)前時(shí)間,最后加上循環(huán)語(yǔ)句讓時(shí)鐘走起來(lái)。(2) 所用到的數(shù)學(xué)公式1. 繪制表盤(pán)(圓):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í)針?lè)轴槪簍heta_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) 程序流程圖開(kāi)始 用極坐標(biāo)與直角坐標(biāo)的關(guān)系繪制圓盤(pá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í)間并畫(huà)出時(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)使表走起來(lái):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)系的單位長(zhǎng)度相同 2. 繪制時(shí)刻度線與分刻度線 theta2=0:2*pi/12:2*pi; for i=1:length(theta2) % 循環(huán)語(yǔ)句繪制時(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)語(yǔ)句繪制分刻度線 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í)針?lè)轴槻⒆x取計(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í)鐘走起來(lái)完成實(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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 全方位醫(yī)療道德責(zé)任精確化的數(shù)據(jù)處理
- 中學(xué)線上教學(xué)工作總結(jié)模版
- AI技術(shù)在醫(yī)學(xué)研究中的應(yīng)用及挑戰(zhàn)探討
- 醫(yī)療糾紛解決中的法律責(zé)任與策略
- 醫(yī)療健康產(chǎn)業(yè)鏈與京味文化的結(jié)合點(diǎn)分析
- 辦公效率提升的人工智能技術(shù)探索與應(yīng)用實(shí)踐案例分享
- ktv合伙投資合同范例
- 醫(yī)療物資供應(yīng)鏈的穩(wěn)定與安全管理探索
- 鄉(xiāng)村振興規(guī)劃合同范例
- 區(qū)塊鏈技術(shù)引領(lǐng)教育管理革新
- 《農(nóng)村基層干部廉潔履行職責(zé)規(guī)定》解讀與培訓(xùn)
- 【MOOC】國(guó)際交英文寫(xiě)作-湖南大學(xué) 中國(guó)大學(xué)慕課MOOC答案
- 虛擬專(zhuān)用網(wǎng)絡(luò)(VPN)技術(shù)課件
- 四年級(jí)英語(yǔ)下unit5sport課件
- 西昌旅游資源介紹課件
- 部編版小學(xué)語(yǔ)文二年級(jí)下冊(cè)教師教學(xué)用書(shū)
- 健康體檢的重大意義共35張課件
- 重大活動(dòng)公共衛(wèi)生安全監(jiān)督保障課件
- 電解質(zhì)溶液導(dǎo)電性影響因素的探究
- GB∕T 13554-2020 高效空氣過(guò)濾器
- 客戶(hù)性格色彩分析
評(píng)論
0/150
提交評(píng)論