




版權(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í)刻度線(xiàn):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繪制分刻度線(xiàn):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í)刻度線(xiàn)與分刻度線(xiàn) theta2=0:2*pi/12:2*pi; for i=1:length(theta2) % 循環(huán)語(yǔ)句繪制時(shí)刻度線(xiàn)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ǔ)句繪制分刻度線(xià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í)針?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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 勞動(dòng)合同范本續(xù)簽版
- 加工承諾合同范本
- 會(huì)展保潔服務(wù)合同范本
- 中介招聘項(xiàng)目合同范本
- 二手垃圾車(chē)買(mǎi)賣(mài)合同范本
- 衛(wèi)生院招標(biāo)代理合同范本
- 2025云南省建筑安全員-C證(專(zhuān)職安全員)考試題庫(kù)
- 出租廚房立柜合同范例
- 南京房屋贈(zèng)與合同范本
- 農(nóng)資尿素采購(gòu)合同范本
- GB/T 31586.2-2015防護(hù)涂料體系對(duì)鋼結(jié)構(gòu)的防腐蝕保護(hù)涂層附著力/內(nèi)聚力(破壞強(qiáng)度)的評(píng)定和驗(yàn)收準(zhǔn)則第2部分:劃格試驗(yàn)和劃叉試驗(yàn)
- GB/T 15175-2012固體激光器主要參數(shù)測(cè)量方法
- 建筑工程施工進(jìn)度計(jì)劃網(wǎng)絡(luò)圖和橫道圖
- HP工作站BIOS詳解參考模板
- 員工培訓(xùn)、考試、積分記錄表
- 微專(zhuān)題:地理時(shí)空“尺度觀”思想課件
- 大學(xué)普通物理-習(xí)題答案(程守洙-江之勇主編-第六版)課件
- 風(fēng)冷熱泵主機(jī)改造-模塊機(jī)匯總
- 烏司他丁課件
- 《工程化學(xué)》全套教學(xué)課件
- 職業(yè)衛(wèi)生工程控制技術(shù)課件
評(píng)論
0/150
提交評(píng)論