【数据分析】学生成绩管理系统含GUI界面
1 简介
信息技术正在逐步深入,广泛的应用到教育管理中,在技术上管理信息系统的实施已逐步成熟.要发展学校信息系统,要高效率地有机地组织内部信息,尤其是进行深化,细致的分析成绩信息,就必须根据自身特点建立相适应的学生成绩管理统计,分析系统.本系统采用"自上而下地总体规划,自下而上地应用开发"的策略,介绍了在matlab境下开发一个管理信息系统的过程.创建了一套行之有效的计算机管理学生成绩的方案.
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});endif 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');%在图形窗口画网格线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'); %显示成绩 elseset(handles.edit1,'string',num2str(handles.chengji(value,:)));%确保edit1中是数字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');endfunction edit1_Callback(hObject, eventdata, handles)function edit1_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');endfunction 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');%建立一个默认参数的错误对话框 return;endtest=FileName(1,end-3:end);%定义一个变量test用于文件类型的确定str=[PathName FileName];set(handles.edit2,'string',str);%使打来的文件路径和文件名显示在edit2global 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);%按行从文件中读取数据,但不读取换行符 [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判断是否为文件结尾 str=fgetl(fin); [name chinese math english]=strread(str,'%s %d %d %d','delimiter',' ');% %d用于输出十进制数 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);%读取数据完成后释放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);%求数学的总分 d3=chengji(1:len,3); ave3=sum(d3);%求英语的总分 fclose(fin); %当文件格式为表格时 case '.xls' %当文件为表格时 h=waitbar(0,'please wait a moment');%创建一个进度条 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);%求数学的总分 d3=chengji(1:len,3); ave3=sum(d3);%求英语的总分 otherwise errordlg('Wrong File','File Open Error'); returnend 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;%求数学的平均分 case 'english' d=d3; ave=ave3/len;%求英语的平均分endguidata(hObject,handles);function popupmenu1_CreateFcn(hObject, eventdata, handles)if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end
3 仿真结果

4 参考文献
[1]张颖. 学生成绩统计,分析软件的设计与实现[D]. 内蒙古师范大学, 2011.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。


