




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、 至誠學(xué)院 MATLAB 實踐 課程設(shè)計學(xué)生姓名: 學(xué) 號: 專業(yè)班級: (2) 指導(dǎo)教師: 二一四 年 四 月 三十 日目 錄1.設(shè)計目的第3頁2.題目分析第3頁3.總體設(shè)計第3頁4.具體設(shè)計第4頁5.小結(jié)和心得第15頁1、 設(shè)計目的:使用MATLAB的GUI程序設(shè)計學(xué)生成績管理系統(tǒng)。完成需學(xué)生成績的基本管理,包含對學(xué)生成績的讀入、修改、添加和查詢等基本的功能。本課題主要解決對學(xué)生成績總體的客觀評價,通過一系列數(shù)據(jù)的分析比較,例如平均值,成績分布等整體數(shù)據(jù)的處理,以及matlab和excel在數(shù)據(jù)聯(lián)動功能方面的應(yīng)用,所繪制的直方圖、正態(tài)分布圖等圖像信息使得分析成績系統(tǒng)更直觀、有效地反映學(xué)生此
2、課程這一階段的表現(xiàn),進而研究今后的教學(xué)重點,以及從教學(xué)到考試等一連串過程中的薄弱環(huán)節(jié),從而達到教學(xué)相長的目的。不論是對學(xué)生的整體學(xué)習(xí)情況還是單獨考慮每個學(xué)生的學(xué)習(xí)情況都能夠進行較好的評價。面比起單純的絕對分數(shù)評價學(xué)生的學(xué)習(xí)狀況,忽略了基礎(chǔ)條件的差異,我們運用了各種方法和模型來去避免這類現(xiàn)象的發(fā)生,動態(tài)的分析每個學(xué)生的情況,并從定性和定量兩方面分別給出了數(shù)值與建議。2、 題目分析 根據(jù)課題的要求,分析成績管理系統(tǒng)的現(xiàn)實需求,我們可以概括為設(shè)計的程序應(yīng)該包含的幾個基本模塊及應(yīng)該完成的功能如下: 1.文件管理:完成成績表格的導(dǎo)入(.xls文件),完成對修改后的成績文件的保存。 2.成績管理:完成對學(xué)
3、生成績、學(xué)號、成績、總分的顯示和修改,還有添加新的學(xué)生的信息。 3.查詢管理:完成對姓名或者學(xué)號的查詢的顯示和刪除,學(xué)生的信息顯示在成績管理里面的顯示框里面。4.在學(xué)生的姓名顯示框點擊學(xué)生姓名,成績管理系統(tǒng)里面自動獲取學(xué)生的基本信息。5.統(tǒng)計出學(xué)生的最高分和最低分以及各科成績的平均分情況。6.通過各科成績的統(tǒng)計分布直方圖,直觀地分析學(xué)生的各科的成績狀況。3、總體設(shè)計 圍繞設(shè)計的題目范圍,我們可以將起繪制成功能模塊的總體模塊圖如下圖1。根據(jù)設(shè)計的模塊設(shè)計成GUI的設(shè)計圖如下圖2。 通過將導(dǎo)入的學(xué)生信息的數(shù)據(jù)保存到全局變量的數(shù)組里面,到每個模塊需要使用時,導(dǎo)出數(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顯示模塊模塊: 顯示模塊需要完成的是對于學(xué)生姓名、序號以及成績的顯示,并且在點擊姓名顯示框里面的學(xué)生姓名時,成績管理的模塊里面可以自動顯示學(xué)生的以上基本信息。設(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è)置姓名顯示的高亮位置表示選中的學(xué)生,調(diào)出handles里面的信息,然后通過set函數(shù)將數(shù)字賦值給顯示框。4.1.2文件管理模塊:文件管理模塊要實現(xiàn)的是對于保存成績的表格文件(.xls文件)的讀取和對于學(xué)生信息修改或者刪除之后的保存功能。因此添加了兩個控件按鈕來
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ù)組的形式,分別給成績、姓名、學(xué)
11、號數(shù)組賦值,并設(shè)置三個list顯示全部學(xué)生的信息,并保存這些數(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成績管理模塊:成績管理模塊需要完成的是對于學(xué)生的姓名、學(xué)號和成績的顯示(顯示在上面的顯示模塊里面完成),以及修改學(xué)生信息的修改和添加新的學(xué)生信息。添加兩個控件,控制學(xué)生信息的修改和添加。界面設(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)出原來的成績、學(xué)號和姓名數(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)出原來的成績、學(xué)號和姓名數(shù)組,根據(jù)新添加的信息,修改原本的三個數(shù)據(jù)的數(shù)值,并保存到全局變量handles里面。4.1.4查詢管理模塊:本模塊需要完成的是通過查詢學(xué)生姓名或者學(xué)號,讓成績管理里面可以顯示該學(xué)生的基本信息并可以通過刪除按鈕刪除該生的信息,沒有查詢到該生的信息,即提示“沒有找到”。通過平均分查詢按鈕來查詢各科的平均分成績。通過查詢學(xué)生姓名,找到學(xué)生的總分并顯示?;驹O(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)出姓名、學(xué)號和成績數(shù)組,獲取需要刪除的學(xué)生在數(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里面這個學(xué)生的信息為高亮,并顯示在成績管理里面。4.1.4.3學(xué)號查詢按鈕的程序設(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 查詢是否有這個學(xué)號在保存的名字的數(shù)組里面,獲取需要刪除的學(xué)號在保存的數(shù)組里面是第幾個的,獲取三個數(shù)組,設(shè)置三個list里面這個學(xué)生的信息為高亮,并顯示在成績管理里面。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里面這個學(xué)生的信息為高亮,同時計算她(他)的總分,并顯示。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è)計比較簡單,僅包含通過點擊查詢最高分或者最低分按鈕來查詢各科學(xué)生成績里面的最高分和最低分并顯示。程序設(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è)計為:將各科學(xué)生的成績分段統(tǒng)計,畫出學(xué)生成績的分布直
37、方圖。采用的分數(shù)段為:060、6170、7180、8190、91100五個分數(shù)段。設(shè)計界面圖如下:4.1.6.1顯示數(shù)學(xué)成績分數(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ù)學(xué)成績分數(shù)段統(tǒng)計直方圖); 調(diào)用數(shù)學(xué)成績數(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 yu
溫馨提示
- 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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025至2030年中國鉚螺母市場分析及競爭策略研究報告
- 2025至2030年中國輸電線路覆冰在線專業(yè)監(jiān)測站市場分析及競爭策略研究報告
- 2025至2030年中國花形風(fēng)車市場分析及競爭策略研究報告
- 2025至2030年中國線繞電位器市場分析及競爭策略研究報告
- 2025至2030年中國短柄水勺市場分析及競爭策略研究報告
- 2025至2030年中國水滸酒市場分析及競爭策略研究報告
- 2025至2030年中國木制棋牌市場分析及競爭策略研究報告
- 2025至2030年中國探傷儀市場分析及競爭策略研究報告
- 2025至2030年中國廣告級霓虹燈粉管市場分析及競爭策略研究報告
- 2025至2030年中國定時器收音機市場分析及競爭策略研究報告
- 金融行業(yè)信息安全培訓(xùn)
- 醫(yī)療廢物管理
- 山東詠坤新材料科技有限公司年產(chǎn)4000噸鋰鈉電池負極材料生產(chǎn)項目報告書
- 中老年人健康教育宣講
- IT云圖2025:中國算力區(qū)域競爭力研究
- 四川省成都市成華區(qū)2023-2024學(xué)年高一下學(xué)期期末考試數(shù)學(xué)試題(解析版)
- 環(huán)衛(wèi)設(shè)備部技能提升與安全管理培訓(xùn)會
- 規(guī)范辦學(xué)專題宣講
- 某地500kW-2MWh用戶側(cè)儲能系統(tǒng)技術(shù)方案(削峰填谷儲能項目)
- 小學(xué)電路知識課件
- 小猴子下山第一課時教學(xué)設(shè)計
評論
0/150
提交評論