版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、 至誠學院 matlab 實踐 課程設(shè)計學生姓名: 學 號: 專業(yè)班級: (2) 指導教師: 二一四 年 四 月 三十 日目 錄1.設(shè)計目的第3頁2.題目分析第3頁3.總體設(shè)計第3頁4.具體設(shè)計第4頁5.小結(jié)和心得第15頁1、 設(shè)計目的:使用matlab的gui程序設(shè)計學生成績管理系統(tǒng)。完成需學生成績的基本管理,包含對學生成績的讀入、修改、添加和查詢等基本的功能。本課題主要解決對學生成績總體的客觀評價,通過一系列數(shù)據(jù)的分析比較,例如平均值,成績分布等整體數(shù)據(jù)的處理,以及matlab和excel在數(shù)據(jù)聯(lián)動功能方面的應(yīng)用,所繪制的直方圖、正態(tài)分布圖等圖像信息使得分析成績系統(tǒng)更直觀、有效地反映學生此
2、課程這一階段的表現(xiàn),進而研究今后的教學重點,以及從教學到考試等一連串過程中的薄弱環(huán)節(jié),從而達到教學相長的目的。不論是對學生的整體學習情況還是單獨考慮每個學生的學習情況都能夠進行較好的評價。面比起單純的絕對分數(shù)評價學生的學習狀況,忽略了基礎(chǔ)條件的差異,我們運用了各種方法和模型來去避免這類現(xiàn)象的發(fā)生,動態(tài)的分析每個學生的情況,并從定性和定量兩方面分別給出了數(shù)值與建議。2、 題目分析 根據(jù)課題的要求,分析成績管理系統(tǒng)的現(xiàn)實需求,我們可以概括為設(shè)計的程序應(yīng)該包含的幾個基本模塊及應(yīng)該完成的功能如下: 1.文件管理:完成成績表格的導入(.xls文件),完成對修改后的成績文件的保存。 2.成績管理:完成對學
3、生成績、學號、成績、總分的顯示和修改,還有添加新的學生的信息。 3.查詢管理:完成對姓名或者學號的查詢的顯示和刪除,學生的信息顯示在成績管理里面的顯示框里面。4.在學生的姓名顯示框點擊學生姓名,成績管理系統(tǒng)里面自動獲取學生的基本信息。5.統(tǒng)計出學生的最高分和最低分以及各科成績的平均分情況。6.通過各科成績的統(tǒng)計分布直方圖,直觀地分析學生的各科的成績狀況。3、總體設(shè)計 圍繞設(shè)計的題目范圍,我們可以將起繪制成功能模塊的總體模塊圖如下圖1。根據(jù)設(shè)計的模塊設(shè)計成gui的設(shè)計圖如下圖2。 通過將導入的學生信息的數(shù)據(jù)保存到全局變量的數(shù)組里面,到每個模塊需要使用時,導出數(shù)據(jù)即可完成對數(shù)據(jù)的引用,在需要完成操
4、作的按鈕下編寫回調(diào)函數(shù)來達到需要完成的功能。設(shè)計內(nèi)容包含對回調(diào)函數(shù)的編寫和對于程序功能的調(diào)試,分析問題原因,在實現(xiàn)程序功能時,進一步改善程序的設(shè)計構(gòu)架。 圖1圖24、具體設(shè)計利用matlab的gui程序設(shè)計實現(xiàn)成績管理系統(tǒng)的功能。各個模塊功能的實現(xiàn)及程序設(shè)計如下:4.1.模塊設(shè)計界面及程序設(shè)計4.1.1顯示模塊模塊: 顯示模塊需要完成的是對于學生姓名、序號以及成績的顯示,并且在點擊姓名顯示框里面的學生姓名時,成績管理的模塊里面可以自動顯示學生的以上基本信息。設(shè)計界面如下:對于姓名顯示框的程序設(shè)計如下:% - executes on selection change in xmlist.func
5、tion xmlist_callback(hobject, eventdata, handles)% hobject handle to xmlist (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)content=get(hobject,value);set(handles.chengjilist,value,content);set(handles.xhlist,val
6、ue,content);chengji=handles.chengji;xingming=handles.xingming;xuehao=handles.xuehao;set(handles.lredit1,string,xingming(content);set(handles.lredit2,string,chengji(content,1);set(handles.lredit3,string,chengji(content,2);set(handles.lredit4,string,xuehao(content,1);set(handles.xmedit,string,xingming
7、(content);set(handles.xuehaoedit,string,xuehao(content);set(handles.lredit13,string,xingming(content)set(handles.zfedit,string,(chengji(content,1)+chengji(content,2); 首先設(shè)置姓名顯示的高亮位置表示選中的學生,調(diào)出handles里面的信息,然后通過set函數(shù)將數(shù)字賦值給顯示框。4.1.2文件管理模塊:文件管理模塊要實現(xiàn)的是對于保存成績的表格文件(.xls文件)的讀取和對于學生信息修改或者刪除之后的保存功能。因此添加了兩個控件按鈕來
8、實現(xiàn),在點擊按鈕后,彈出讀?。ɑ虮4妫┪募乃谖恢?,添加文件后,系統(tǒng)完成對成績的讀?。ɑ虮4妫┕δ堋]有選中文件時,提示“沒有選擇文件”。設(shè)計界面如下:4.1.2.1打開成績文件的按鈕的設(shè)計程序:% - executes on button press in pushbutton1.function pushbutton1_callback(hobject, eventdata, handles)% hobject handle to pushbutton1 (see gcbo)% eventdata reserved - to be defined in a future version
9、of matlab% handles structure with handles and user data (see guidata)filename,pathname=uigetfile(*.xls;*.*,打開成績文件);if isequal(filename,0)|isequal(pathname,0) errordlg(沒有選擇文件,出錯); returnelse str=pathname,filename; word,txt=xlsread(str); xingming=txt(2:end,1); xuehao=word(1:end,1); chengji=word(1:end,
10、2:3); set(handles.xmlist,string,xingming); set(handles.chengjilist,string,num2str(chengji); set(handles.xhlist,string,num2str(xuehao); handles.count=length(xingming); handles.chengji=chengji; handles.xuehao=xuehao; handles.xingming=xingming; guidata(hobject,handles);end 讀取文件里面的信息,保存為數(shù)組的形式,分別給成績、姓名、學
11、號數(shù)組賦值,并設(shè)置三個list顯示全部學生的信息,并保存這些數(shù)據(jù)到全局變量handles里面。4.1.2.2保存文件按鈕設(shè)計程序:% - executes on button press in baocunbutton.function baocunbutton_callback(hobject, eventdata, handles)% hobject handle to baocunbutton (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure wi
12、th handles and user data (see guidata)filename,pathname=uigetfile(*.xls;*.*,打開成績文件);if isequal(filename,0)|isequal(pathname,0) errordlg(沒有選擇文件,出錯); returnelse str=pathname,filename; xingming=handles.xingming; chengji=handles.chengji; xuehao=handles.xuehao; oldcount=handles.count; row,co=size(chengji
13、); col=co+1; if rowoldcount m=cell(oldcount,col); else m=cell(row,col); end m(1:row,1)=xingming; m(1:row,2)=num2cell(xuehao); m(1:row,3:col+1)=num2cell(chengji); xlswrite(str,m,1,a2); handles.count=row; guidata(hobject,row);end 將新獲取的數(shù)據(jù)保存到m數(shù)組里面,調(diào)出原本數(shù)組的行數(shù)count,比較新獲得的數(shù)組的行數(shù)和原來行數(shù)count的大小,根據(jù)實際調(diào)節(jié)寫入數(shù)組的大小,并保
14、存新的數(shù)據(jù)的行數(shù)。4.1.3成績管理模塊:成績管理模塊需要完成的是對于學生的姓名、學號和成績的顯示(顯示在上面的顯示模塊里面完成),以及修改學生信息的修改和添加新的學生信息。添加兩個控件,控制學生信息的修改和添加。界面設(shè)計圖如下:4.1.3.1修改按鈕的程序設(shè)計:% - executes on button press in pushbutton2.function pushbutton2_callback(hobject, eventdata, handles)% hobject handle to pushbutton2 (see gcbo)% eventdata reserved - t
15、o be defined in a future version of matlab% handles structure with handles and user data (see guidata)content=get(handles.xmlist,value);xingming=handles.xingming;chengji=handles.chengji;xuehao=handles.xuehao;newname=get(handles.lredit1,string);shuxue=str2num(get(handles.lredit2,string);yuwen=str2num
16、(get(handles.lredit3,string);newxuehao=str2num(get(handles.lredit4,string);xingming(content)=newname;chengji(content,:)=shuxue,yuwen;xuehao(content)=newxuehao;set(handles.xmlist,string,xingming);set(handles.chengjilist,string,num2str(chengji);set(handles.xhlist,string,num2str(xuehao);handles.xuehao=
17、xuehao;handles.xingming=xingming;handles.chengji=chengji;guidata(hobject,handles); 獲取輸入的數(shù)據(jù),調(diào)出原來的成績、學號和姓名數(shù)組,根據(jù)新修改的信息,修改原本的三個數(shù)據(jù)的數(shù)值,并保存到全局變量handles里面。4.1.3.2添加按鈕的程序設(shè)計:% - executes on button press in tianjiabutton.function tianjiabutton_callback(hobject, eventdata, handles)% hobject handle to tianjiabut
18、ton (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)newname=get(handles.lredit1,string);shuxue=str2num(get(handles.lredit2,string);yuwen=str2num(get(handles.lredit3,string);newxuehao=str2num(get(handles.lredit4,s
19、tring);handles.xingming=handles.xingming;newname;handles.chengji=handles.chengji;shuxue,yuwen;handles.xuehao=handles.xuehao;newxuehao;guidata(hobject,handles);set(handles.xmlist,string,handles.xingming);set(handles.xhlist,string,num2str(handles.xuehao);set(handles.chengjilist,string,num2str(handles.
20、chengji); 獲取輸入的數(shù)據(jù),調(diào)出原來的成績、學號和姓名數(shù)組,根據(jù)新添加的信息,修改原本的三個數(shù)據(jù)的數(shù)值,并保存到全局變量handles里面。4.1.4查詢管理模塊:本模塊需要完成的是通過查詢學生姓名或者學號,讓成績管理里面可以顯示該學生的基本信息并可以通過刪除按鈕刪除該生的信息,沒有查詢到該生的信息,即提示“沒有找到”。通過平均分查詢按鈕來查詢各科的平均分成績。通過查詢學生姓名,找到學生的總分并顯示。基本設(shè)計模塊如下圖:4.1.4.1兩個刪除按鈕的程序設(shè)計(以第一個刪除為例,第二個原理同第一個):% - executes on button press in shanchubutton
21、.function shanchubutton_callback(hobject, eventdata, handles)% hobject handle to shanchubutton (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)name=get(handles.xmedit,string);lia,id=ismember(name,handles.xingming
22、);if lia xingming=handles.xingming; chengji=handles.chengji; xuehao=handles.xuehao; xingming(id)=; xuehao(id)=; chengji(id,:)=; handles.chengji=chengji; handles.xuehao=xuehao; handles.xingming=xingming; guidata(hobject,handles); set(handles.xmlist,string,xingming); set(handles.chengjilist,string,num
23、2str(chengji); set(handles.xhlist,string,num2str(xuehao); set(handles.xmlist,value,1); set(handles.xhlist,value,1); set(handles.chengjilist,value,1);else 查詢時候有這個名字在保存的名字(或?qū)W號)的數(shù)組里面,調(diào)出姓名、學號和成績數(shù)組,獲取需要刪除的學生在數(shù)組里面保存在第幾個的位置,將數(shù)組里面的這兒位置清空,設(shè)置三個list的顯示高亮位置回到第一行,同時更新handles里面的三個數(shù)組存放。4.1.4.2姓名查詢按鈕的程序設(shè)計:% - execu
24、tes on button press in chaxunbutton.function chaxunbutton_callback(hobject, eventdata, handles)% hobject handle to chaxunbutton (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)name=get(handles.xmedit,string);lia,
25、id=ismember(name,handles.xingming);if lia set(handles.xmlist,value,id); set(handles.xhlist,value,id); set(handles.chengjilist,value,id); xingming=handles.xingming; chengji=handles.chengji; xuehao=handles.xuehao; set(handles.lredit1,string,xingming(id); set(handles.lredit2,string,chengji(id,1); set(h
26、andles.lredit3,string,chengji(id,2); set(handles.lredit4,string,xuehao(id);else msgbox(沒有找到);end 查詢是否有這個名字在保存的名字的數(shù)組里面,獲取需要刪除的名字在保存的數(shù)組里面是第幾個的,獲取三個數(shù)組,設(shè)置三個list里面這個學生的信息為高亮,并顯示在成績管理里面。4.1.4.3學號查詢按鈕的程序設(shè)計:% - executes on button press in pushbutton9.function pushbutton9_callback(hobject, eventdata, handles
27、)% hobject handle to pushbutton9 (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)xh=get(handles.xuehaoedit,string);lia,id=ismember(str2num(xh),handles.xuehao);if lia set(handles.xmlist,value,id); set(handles.xhli
28、st,value,id); set(handles.chengjilist,value,id); xingming=handles.xingming; chengji=handles.chengji; xuehao=handles.xuehao; set(handles.lredit1,string,xingming(id); set(handles.lredit2,string,chengji(id,1); set(handles.lredit3,string,chengji(id,2); set(handles.lredit4,string,xuehao(id);else msgbox(沒
29、有找到);end 查詢是否有這個學號在保存的名字的數(shù)組里面,獲取需要刪除的學號在保存的數(shù)組里面是第幾個的,獲取三個數(shù)組,設(shè)置三個list里面這個學生的信息為高亮,并顯示在成績管理里面。4.1.4.4總分查詢按鈕的程序設(shè)計:% - executes on button press in zfbutton.function zfbutton_callback(hobject, eventdata, handles)% hobject handle to zfbutton (see gcbo)% eventdata reserved - to be defined in a future versi
30、on of matlab% handles structure with handles and user data (see guidata)name=get(handles.lredit13,string);lia,id=ismember(name,handles.xingming);if lia set(handles.xmlist,value,id); set(handles.xhlist,value,id); set(handles.chengjilist,value,id); xingming=handles.xingming; chengji=handles.chengji; x
31、uehao=handles.xuehao; set(handles.zfedit,string,(chengji(id,1)+chengji(id,2);else msgbox(沒有找到);end 查詢是否有這個名字在保存的名字的數(shù)組里面,獲取需要刪除的名字在保存的數(shù)組里面是第幾個的,獲取三個數(shù)組,設(shè)置三個list里面這個學生的信息為高亮,同時計算她(他)的總分,并顯示。4.1.4.5平均分查詢按鈕的程序設(shè)計:% - executes on button press in pjfbutton.function pjfbutton_callback(hobject, eventdata, han
32、dles)% hobject handle to pjfbutton (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)chengji=handles.chengji;shuxue=chengji(1:end,1);yuwen=chengji(1:end,2);avesshuxue=mean(shuxue);avesyuwen=mean(yuwen);set(handles.
33、sxedit,string,num2str(avesshuxue);set(handles.ywedit,string,num2str(avesyuwen); 通過按鈕,調(diào)用成績數(shù)組,計算平均分并顯示。4.1.5成績概況模塊:成績概況的設(shè)計比較簡單,僅包含通過點擊查詢最高分或者最低分按鈕來查詢各科學生成績里面的最高分和最低分并顯示。程序設(shè)計界面如下:4.1.5.1最高分按鈕程序設(shè)計:% - executes on button press in pushbutton7.function pushbutton7_callback(hobject, eventdata, handles)% hob
34、ject handle to pushbutton7 (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)chengji=handles.chengji;count=handles.count;x=max(chengji(1:count,1);y=max(chengji(1:count,2);set(handles.lredit6,string,num2str(x);set(h
35、andles.lredit7,string,num2str(y); 調(diào)用成績數(shù)組,根據(jù)人數(shù),設(shè)置比較次數(shù),按照科目比較,并設(shè)置顯示。4.1.5.2最低分程序設(shè)計:% - executes on button press in pushbutton8.function pushbutton8_callback(hobject, eventdata, handles)% hobject handle to pushbutton8 (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles
36、 structure with handles and user data (see guidata)chengji=handles.chengji;count=handles.count;x=min(chengji(1:count,1);y=min(chengji(1:count,2);set(handles.lredit8,string,num2str(x);set(handles.lredit9,string,num2str(y); 調(diào)用成績數(shù)組,根據(jù)人數(shù),設(shè)置比較次數(shù),按照科目比較,并設(shè)置顯示。4.1.6成績統(tǒng)計直方圖模塊:本模塊的設(shè)計為:將各科學生的成績分段統(tǒng)計,畫出學生成績的分布直
37、方圖。采用的分數(shù)段為:060、6170、7180、8190、91100五個分數(shù)段。設(shè)計界面圖如下:4.1.6.1顯示數(shù)學成績分數(shù)段統(tǒng)計直方圖按鈕的程序設(shè)計:% - executes on button press in zftbutton.function zftbutton_callback(hobject, eventdata, handles)% hobject handle to zftbutton (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structur
38、e with handles and user data (see guidata)axes(handles.axes1);cla;chengji=handles.chengji;shuxue=chengji(1:end,1);count=handles.count;aa=0 0 0 0 0;for i=1:count if shuxue(i)60 aa(1)=aa(1)+1; else if shuxue(i)70 aa(2)=aa(2)+1; else if shuxue(i)80 aa(3)=aa(3)+1; else if shuxue(i)90 aa(4)=aa(4)+1; else
39、 aa(5)=aa(5)+1; end end end endendx=50 65 75 85 95; bar(x,aa);title(數(shù)學成績分數(shù)段統(tǒng)計直方圖); 調(diào)用數(shù)學成績數(shù)組,設(shè)定空數(shù)組aa用來存放分數(shù)段的統(tǒng)計數(shù)據(jù)。設(shè)定循環(huán)函數(shù),分別比較五個數(shù)值:60、70、80、90、100,并記錄。最后用bar函數(shù)畫出函數(shù)圖像。4.1.6.2顯示語文成績分數(shù)段統(tǒng)計直方圖:% - executes on button press in pushbutton14.function pushbutton14_callback(hobject, eventdata, handles)% hobject h
40、andle to pushbutton14 (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)axes(handles.axes2);cla;chengji=handles.chengji;yuwen=chengji(1:end,2);count=handles.count;aa=0 0 0 0 0;for i=1:count if yuwen(i)60 aa(1)=aa(1)+1; else if
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025廣東肇慶高新區(qū)總工會招聘社會化工會工作者9人(公共基礎(chǔ)知識)綜合能力測試題附答案
- 2025江西吉安市青原區(qū)睿才人力資源有限公司招聘6人模擬試卷附答案
- 2025年湖南婁底市消防救援支隊政府專職消防員招聘116人備考題庫附答案
- 2025山東濟南政金投資有限公司招聘10人參考題庫附答案
- 2025寧夏銀川市實驗中學辦公室行政干事招聘1人考試歷年真題匯編附答案
- 2026重慶飛駛特人力資源管理有限公司外派至招商局檢測車輛技術(shù)研究院有限公司招聘筆試模擬試題及答案解析
- 2026江蘇南京教育局直屬學校招聘教師58人筆試備考題庫及答案解析
- 2026廣東東莞市公安局石排分局第1批警務(wù)輔助人員招聘21人筆試備考題庫及答案解析
- 2026年舟山嵊泗縣衛(wèi)生健康局下屬事業(yè)單位公開招聘中醫(yī)醫(yī)生類工作人員1人筆試備考題庫及答案解析
- 2026年徽商銀行客服代表(勞務(wù)派遣制)招聘筆試備考試題及答案解析
- 2026北京市通州區(qū)事業(yè)單位公開招聘工作人員189人筆試重點基礎(chǔ)提升(共500題)附帶答案詳解
- 2025~2026學年山東省菏澤市牡丹區(qū)第二十一初級中學八年級上學期期中歷史試卷
- 土壓平衡盾構(gòu)克泥效同步注入抑制沉降施工工法
- QSB知識培訓資料重點
- 安全庫存基準表
- (37)-24.1.4黃芪中藥中醫(yī)學課件
- 高中生物競賽課件:蛋白質(zhì)的性質(zhì)與分離、分析技術(shù)
- 刑法學(上冊)馬工程課件 第1章 刑法概說
- 《紅樓夢中的禮儀習俗研究報告》
- GB/T 1041-2008塑料壓縮性能的測定
- 全國計算機等級考試三級網(wǎng)絡(luò)技術(shù)歷年真題版
評論
0/150
提交評論