【數(shù)據(jù)分析】學生成績管理系統(tǒng)含GUI界面
1 簡介
信息技術(shù)正在逐步深入,廣泛的應用到教育管理中,在技術(shù)上管理信息系統(tǒng)的實施已逐步成熟.要發(fā)展學校信息系統(tǒng),要高效率地有機地組織內(nèi)部信息,尤其是進行深化,細致的分析成績信息,就必須根據(jù)自身特點建立相適應的學生成績管理統(tǒng)計,分析系統(tǒng).本系統(tǒng)采用"自上而下地總體規(guī)劃,自下而上地應用開發(fā)"的策略,介紹了在matlab境下開發(fā)一個管理信息系統(tǒng)的過程.創(chuàng)建了一套行之有效的計算機管理學生成績的方案.
2 部分代碼
function varargout = chengji(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', ? ? ? mfilename, ...
? ? ? ? ? ? ? ? ? 'gui_Singleton', ?gui_Singleton, ...
? ? ? ? ? ? ? ? ? 'gui_OpeningFcn', @chengji_OpeningFcn, ...
? ? ? ? ? ? ? ? ? 'gui_OutputFcn', ?@chengji_OutputFcn, ...
? ? ? ? ? ? ? ? ? 'gui_LayoutFcn', ?[] , ...
? ? ? ? ? ? ? ? ? 'gui_Callback', ? []);
if nargin && ischar(varargin{1})
? ?gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
? ?[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
? ?gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before chengji is made visible.
function chengji_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
Hc_grid=uicontrol(gcf,'style','toggle','string','Grid','position',[650 165 60 29],'callback','grid');%在圖形窗口畫網(wǎng)格線
guidata(hObject, handles);
function varargout = chengji_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
value=get(hObject,'value')-1;
if(value==0)
?set(handles.edit1,'string','please choose a name'); %顯示成績
else
set(handles.edit1,'string',num2str(handles.chengji(value,:)));%確保edit1中是數(shù)字
end
% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
? ?set(hObject,'BackgroundColor','white');
end
function edit1_Callback(hObject, eventdata, handles)
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
? ?set(hObject,'BackgroundColor','white');
end
function edit2_Callback(hObject, eventdata, handles)
function edit2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
? ?set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
[FileName PathName]=uigetfile({'*.xls','Excel Files(*.xls)';'*.txt','Text Files(*.txt)';'*.*','All Files(*.*)'},'Choose a file');%uigetfile用來選擇讀入的文件
L=length(FileName);
if(L<5)
? ?errordlg('請選擇正確文件','File Open Error');%建立一個默認參數(shù)的錯誤對話框
? ?return;
end
test=FileName(1,end-3:end);%定義一個變量test用于文件類型的確定
str=[PathName FileName];
set(handles.edit2,'string',str);%使打來的文件路徑和文件名顯示在edit2
global len;global ave1;global ave2;global ave3;
global d1;global d2;global d3;
switch test
? ?case '.txt' %當文件為記事本時
? ?fin=fopen('chengji.txt','r');
? ?str=fgetl(fin);%按行從文件中讀取數(shù)據(jù),但不讀取換行符
? ?[str1 str2 str3 str4]=strread(str,'%s %s %s %s','delimiter',' ');%delimiter用于指定分隔符;%s:輸出字符串
? ?xingming(1)=str1;%就是單詞name
? ?counter=2;
? ?h=waitbar(0,'please wait a moment,reading the file now ............');
? ?for i=1:100,
? ? ? ?waitbar(i/100,'h',[num2str(i),'%'])%顯示百分比
? ? ? ?pause(.1)
? ?end
? ?while feof(fin)==0 ?%feof判斷是否為文件結(jié)尾
? ? ? ? ?str=fgetl(fin);
? ? ? ? ?[name chinese math english]=strread(str,'%s %d %d %d','delimiter',' ?');% %d用于輸出十進制數(shù)
? ? ? ? ?xingming(counter)=name;%讀取學生姓名
? ? ? ? ?chengji(counter-1,:)=[chinese math english];%定義一個成績的矩陣用于儲存成績
? ? ? ? ?counter=counter+1;
? ? ? ? ?waitbar(counter/(counter+1),h,'On working......');
? ?end
? ?waitbar(1,h,'Finished');
? ?delete(h);%讀取數(shù)據(jù)完成后釋放h對象
? ?set(handles.listbox1,'string',xingming);
? ?handles.chengji=chengji; ? ?
? ?len=length(chengji);%求矩陣的長度
? ?d1=chengji(1:len,1);
? ?ave1=sum(d1);%求語文的總分
? ?d2=chengji(1:len,2);
? ?ave2=sum(d2);%求數(shù)學的總分
? ?d3=chengji(1:len,3);
? ?ave3=sum(d3);%求英語的總分
? ?fclose(fin);
? ?%當文件格式為表格時
? ?case '.xls' %當文件為表格時
? ?h=waitbar(0,'please wait a moment');%創(chuàng)建一個進度條
? ?for i=1:100,
? ? ? ?waitbar(i/100,h,[num2str(i),'%'])%顯示百分比
? ? ? ?pause(.1)
? ?end
? ?waitbar(1,h,'Finished');
? ?delete(h);
? ?[chengji xingming]=xlsread(str);
? ?set(handles.listbox1,'string',xingming(:,1));
? ?handles.chengji=chengji;
? ?len=length(chengji);%求矩陣的長度
? ?d1=chengji(1:len,1);
? ?ave1=sum(d1);%求語文的總分
? ?d2=chengji(1:len,2);
? ?ave2=sum(d2);%求數(shù)學的總分
? ?d3=chengji(1:len,3);
? ?ave3=sum(d3);%求英語的總分
? ?otherwise
? ? ? ?errordlg('Wrong File','File Open Error');
? ? ? ?return
end
?guidata(hObject,handles);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
clc;
clear all;
close(gcf);
function pushbutton1_CreateFcn(hObject, eventdata, handles)
function popupmenu1_Callback(hObject, eventdata, handles)
val=get(hObject,'Value');
str=get(hObject,'String');
global len;
global d1;global d2;global d3;
global d;
global ave1;global ave2;global ave3;
global ave;
switch str{val} ? ?
? ?case 'chinese'
? ? ? ?d=d1;
? ? ? ?ave=ave1/len;%求語文的平均分
? ?case ?'math'
? ? ? d=d2;
? ? ? ave=ave2/len;%求數(shù)學的平均分
? ?case 'english'
? ? ? d=d3;
? ? ? ave=ave3/len;%求英語的平均分
end
guidata(hObject,handles);
function popupmenu1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
? ?set(hObject,'BackgroundColor','white');
end
3 仿真結(jié)果

4 參考文獻
[1]張穎. 學生成績統(tǒng)計,分析軟件的設計與實現(xiàn)[D]. 內(nèi)蒙古師范大學, 2011.
博主簡介:擅長智能優(yōu)化算法、神經(jīng)網(wǎng)絡預測、信號處理、元胞自動機、圖像處理、路徑規(guī)劃、無人機等多種領域的Matlab仿真,相關(guān)matlab代碼問題可私信交流。
部分理論引用網(wǎng)絡文獻,若有侵權(quán)聯(lián)系博主刪除。
