1 简介 研究成绩管理系统可以极大地减少管理人员的工作量,系统地对学生的成绩和学生个人信息进行分析和做进一步处理.本文主要采用MATLAB的GUI界面,通过GUI制作一个简单的成绩查询系
1 简介
研究成绩管理系统可以极大地减少管理人员的工作量,系统地对学生的成绩和学生个人信息进行分析和做进一步处理.本文主要采用MATLAB的GUI界面,通过GUI制作一个简单的成绩查询系统界面.方便管理者管理学生的成绩和各类信息,使学校成绩管理和查询方法更科学和有效.
2 部分代码
function varargout = chengjichaxun(varargin)% CHENGJICHAXUN M-file for chengjichaxun.fig
% CHENGJICHAXUN, by itself, creates a new CHENGJICHAXUN or raises the existing
% singleton*.
%
% H = CHENGJICHAXUN returns the handle to a new CHENGJICHAXUN or the handle to
% the existing singleton*.
%
% CHENGJICHAXUN('Property','Value',...) creates a new CHENGJICHAXUN using the
% given property value pairs. Unrecognized properties are passed via
% varargin to chengjichaxun_OpeningFcn. This calling syntax produces a
% warning when there is an existing singleton*.
%
% CHENGJICHAXUN('CALLBACK') and CHENGJICHAXUN('CALLBACK',hObject,...) call the
% local function named CALLBACK in CHENGJICHAXUN.M with the given input
% arguments.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help chengjichaxun
% Last Modified by GUIDE v2.5 09-Jan-2014 16:38:01
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @chengjichaxun_OpeningFcn, ...
'gui_OutputFcn', @chengjichaxun_OutputFcn, ...
'gui_LayoutFcn', [], ...
'gui_Callback', []);
if nargin & isstr(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 chengjichaxun is made visible.
function chengjichaxun_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin unrecognized PropertyName/PropertyValue pairs from the
% command line (see VARARGIN)
% Choose default command line output for chengjichaxun
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes chengjichaxun wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = chengjichaxun_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes during object creation, after setting all properties.
function edit_xm_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_xm (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit_xm_Callback(hObject, eventdata, handles)
% hObject handle to edit_xm (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_xm as text
% str2double(get(hObject,'String')) returns contents of edit_xm as a double
% --- Executes during object creation, after setting all properties.
function edit_xh_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_xh (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit_xh_Callback(hObject, eventdata, handles)
% hObject handle to edit_xh (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_xh as text
% str2double(get(hObject,'String')) returns contents of edit_xh as a double
% --- Executes during object creation, after setting all properties.
function edit_yw_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_yw (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit_yw_Callback(hObject, eventdata, handles)
% hObject handle to edit_yw (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_yw as text
% str2double(get(hObject,'String')) returns contents of edit_yw as a double
% --- Executes during object creation, after setting all properties.
function edit_sx_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_sx (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit_sx_Callback(hObject, eventdata, handles)
% hObject handle to edit_sx (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_sx as text
% str2double(get(hObject,'String')) returns contents of edit_sx as a double
% --- Executes during object creation, after setting all properties.
function edit_yy_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_yy (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit_yy_Callback(hObject, eventdata, handles)
% hObject handle to edit_yy (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_yy as text
% str2double(get(hObject,'String')) returns contents of edit_yy as a double
% --- Executes during object creation, after setting all properties.
function edit_wl_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_wl (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit_wl_Callback(hObject, eventdata, handles)
% hObject handle to edit_wl (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_wl as text
% str2double(get(hObject,'String')) returns contents of edit_wl as a double
% --- Executes during object creation, after setting all properties.
function edit_hx_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_hx (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit_hx_Callback(hObject, eventdata, handles)
% hObject handle to edit_hx (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_hx as text
% str2double(get(hObject,'String')) returns contents of edit_hx as a double
% --- Executes during object creation, after setting all properties.
function edit_sw_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_sw (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit_sw_Callback(hObject, eventdata, handles)
% hObject handle to edit_sw (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_sw as text
% str2double(get(hObject,'String')) returns contents of edit_sw as a double
% --- Executes during object creation, after setting all properties.
function edit_cxxm_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_cxxm (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit_cxxm_Callback(hObject, eventdata, handles)
% hObject handle to edit_cxxm (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_cxxm as text
% str2double(get(hObject,'String')) returns contents of edit_cxxm as a double
% --- Executes during object creation, after setting all properties.
function edit_cxxh_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_cxxh (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit_cxxh_Callback(hObject, eventdata, handles)
% hObject handle to edit_cxxh (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_cxxh as text
% str2double(get(hObject,'String')) returns contents of edit_cxxh as a double
% --- Executes on button press in cxcj.
function cxcj_Callback(hObject, eventdata, handles)
% hObject handle to cxcj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
xm=get(handles.edit_cxxm,'string');
xm=xm(find(xm~=' '));
if length(xm)==0
xh=get(handles.edit_cxxh,'string');
xh=xh(find(xh~=' '));
chaxuntiaojian=str2num(xh);
xunzhao=str2num(handles.chengjibiao.xuehao); %通过学号寻找
weizhi=find(xunzhao==chaxuntiaojian); %将查询学号对应的在成绩表中的位置获得
else
chaxuntiaojian=xm;
xunzhao=handles.chengjibiao.xingming; %通过姓名寻找
[m,n]=size(xunzhao);
l=length(chaxuntiaojian);
buchang(1:n-l)=' '; %将短的姓名补长
chaxuntiaojian=[chaxuntiaojian buchang];
for iii=1:m
chaxunjieguo=(xunzhao(iii,:)==chaxuntiaojian);
if sum(chaxunjieguo)==n
weizhi=iii;
break;
end
end
end
xm=handles.chengjibiao.xingming(weizhi,:);
xh=handles.chengjibiao.xuehao(weizhi,:);
yw=handles.chengjibiao.yuwen(weizhi,:);
sx=handles.chengjibiao.shuxue(weizhi,:);
yy=handles.chengjibiao.yingyu(weizhi,:);
wl=handles.chengjibiao.wuli(weizhi,:);
hx=handles.chengjibiao.huaxue(weizhi,:);
sw=handles.chengjibiao.shengwu(weizhi,:);
zf=handles.chengjibiao.zongfen(weizhi,:);
set(handles.edit_xm,'string',xm);
set(handles.edit_xh,'string',xh);
set(handles.edit_yw,'string',yw);
set(handles.edit_sx,'string',sx);
set(handles.edit_yy,'string',yy);
set(handles.edit_wl,'string',wl);
set(handles.edit_hx,'string',hx);
set(handles.edit_sw,'string',sw);
set(handles.edit_zf,'string',zf);
% --- Executes during object creation, after setting all properties.
function zfpj_CreateFcn(hObject, eventdata, handles)
% hObject handle to zfpj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function zfpj_Callback(hObject, eventdata, handles)
% hObject handle to zfpj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of zfpj as text
% str2double(get(hObject,'String')) returns contents of zfpj as a double
% --- Executes on button press in zfpm.
function zfpm_Callback(hObject, eventdata, handles)
% hObject handle to zfpm (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
zongfen=str2num(handles.chengjibiao.zongfen); %获得每个人的总分
[m,n]=size(zongfen); %获取人数,为m
zf_pj=sum(zongfen)/m; %求得总分的平均分
set(handles.zfpj,'string',num2str(zf_pj)) %显示总分平均分
%%%%%按总分排名
[fenshu mingci]=sort(zongfen); %将总分进行排名,获得各人的名次
chengjibiao.xingming=handles.chengjibiao.xingming(mingci,:);
chengjibiao.xuehao=handles.chengjibiao.xuehao(mingci,:);
chengjibiao.yuwen=handles.chengjibiao.yuwen(mingci,:);
chengjibiao.shuxue=handles.chengjibiao.shuxue(mingci,:);
chengjibiao.yingyu=handles.chengjibiao.yingyu(mingci,:);
chengjibiao.wuli=handles.chengjibiao.wuli(mingci,:);
chengjibiao.huaxue=handles.chengjibiao.huaxue(mingci,:);
chengjibiao.shengwu=handles.chengjibiao.shengwu(mingci,:);
chengjibiao.zongfen=handles.chengjibiao.zongfen(mingci,:);
set(handles.edit_xm,'string',chengjibiao.xingming);
set(handles.edit_xh,'string',chengjibiao.xuehao);
set(handles.edit_yw,'string',chengjibiao.yuwen);
set(handles.edit_sx,'string',chengjibiao.shuxue);
set(handles.edit_yy,'string',chengjibiao.yingyu);
set(handles.edit_wl,'string',chengjibiao.wuli);
set(handles.edit_hx,'string',chengjibiao.huaxue);
set(handles.edit_sw,'string',chengjibiao.shengwu);
set(handles.edit_zf,'string',chengjibiao.zongfen);
% --- Executes on button press in ywpm.
function ywpm_Callback(hObject, eventdata, handles)
% hObject handle to ywpm (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
yuwen=str2num(handles.chengjibiao.yuwen); %获得每个人的语文分数
[m,n]=size(yuwen); %获取人数,为m
yw_pj=sum(yuwen)/m; %求得语文的平均分
set(handles.ywpj,'string',num2str(yw_pj)) %显示总分平均分
%%%%%按总分排名
[fenshu mingci]=sort(yuwen); %将总分进行排名,获得各人的名次
chengjibiao.xingming=handles.chengjibiao.xingming(mingci,:);
chengjibiao.xuehao=handles.chengjibiao.xuehao(mingci,:);
chengjibiao.yuwen=handles.chengjibiao.yuwen(mingci,:);
chengjibiao.shuxue=handles.chengjibiao.shuxue(mingci,:);
chengjibiao.yingyu=handles.chengjibiao.yingyu(mingci,:);
chengjibiao.wuli=handles.chengjibiao.wuli(mingci,:);
chengjibiao.huaxue=handles.chengjibiao.huaxue(mingci,:);
chengjibiao.shengwu=handles.chengjibiao.shengwu(mingci,:);
chengjibiao.zongfen=handles.chengjibiao.zongfen(mingci,:);
set(handles.edit_xm,'string',chengjibiao.xingming);
set(handles.edit_xh,'string',chengjibiao.xuehao);
set(handles.edit_yw,'string',chengjibiao.yuwen);
set(handles.edit_sx,'string',chengjibiao.shuxue);
set(handles.edit_yy,'string',chengjibiao.yingyu);
set(handles.edit_wl,'string',chengjibiao.wuli);
set(handles.edit_hx,'string',chengjibiao.huaxue);
set(handles.edit_sw,'string',chengjibiao.shengwu);
set(handles.edit_zf,'string',chengjibiao.zongfen);
% --- Executes on button press in sxpm.
function sxpm_Callback(hObject, eventdata, handles)
% hObject handle to sxpm (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
shuxue=str2num(handles.chengjibiao.shuxue); %获得每个人的数学分数
[m,n]=size(shuxue); %获取人数,为m
sx_pj=sum(shuxue)/m; %求得数学的平均分
set(handles.sxpj,'string',num2str(sx_pj)) %显示数学平均分
%%%%%按数学排名
[fenshu mingci]=sort(shuxue); %将总分进行排名,获得各人的名次
chengjibiao.xingming=handles.chengjibiao.xingming(mingci,:);
chengjibiao.xuehao=handles.chengjibiao.xuehao(mingci,:);
chengjibiao.yuwen=handles.chengjibiao.yuwen(mingci,:);
chengjibiao.shuxue=handles.chengjibiao.shuxue(mingci,:);
chengjibiao.yingyu=handles.chengjibiao.yingyu(mingci,:);
chengjibiao.wuli=handles.chengjibiao.wuli(mingci,:);
chengjibiao.huaxue=handles.chengjibiao.huaxue(mingci,:);
chengjibiao.shengwu=handles.chengjibiao.shengwu(mingci,:);
chengjibiao.zongfen=handles.chengjibiao.zongfen(mingci,:);
set(handles.edit_xm,'string',chengjibiao.xingming);
set(handles.edit_xh,'string',chengjibiao.xuehao);
set(handles.edit_yw,'string',chengjibiao.yuwen);
set(handles.edit_sx,'string',chengjibiao.shuxue);
set(handles.edit_yy,'string',chengjibiao.yingyu);
set(handles.edit_wl,'string',chengjibiao.wuli);
set(handles.edit_hx,'string',chengjibiao.huaxue);
set(handles.edit_sw,'string',chengjibiao.shengwu);
set(handles.edit_zf,'string',chengjibiao.zongfen);
% --- Executes on button press in yypm.
function yypm_Callback(hObject, eventdata, handles)
% hObject handle to yypm (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
yingyu=str2num(handles.chengjibiao.yingyu); %获得每个人的英语分数
[m,n]=size(yingyu); %获取人数,为m
yy_pj=sum(yingyu)/m; %求得数学的平均分
set(handles.yypj,'string',num2str(yy_pj)) %显示数学平均分
%%%%%按数学排名
[fenshu mingci]=sort(yingyu); %将总分进行排名,获得各人的名次
chengjibiao.xingming=handles.chengjibiao.xingming(mingci,:);
chengjibiao.xuehao=handles.chengjibiao.xuehao(mingci,:);
chengjibiao.yuwen=handles.chengjibiao.yuwen(mingci,:);
chengjibiao.shuxue=handles.chengjibiao.shuxue(mingci,:);
chengjibiao.yingyu=handles.chengjibiao.yingyu(mingci,:);
chengjibiao.wuli=handles.chengjibiao.wuli(mingci,:);
chengjibiao.huaxue=handles.chengjibiao.huaxue(mingci,:);
chengjibiao.shengwu=handles.chengjibiao.shengwu(mingci,:);
chengjibiao.zongfen=handles.chengjibiao.zongfen(mingci,:);
set(handles.edit_xm,'string',chengjibiao.xingming);
set(handles.edit_xh,'string',chengjibiao.xuehao);
set(handles.edit_yw,'string',chengjibiao.yuwen);
set(handles.edit_sx,'string',chengjibiao.shuxue);
set(handles.edit_yy,'string',chengjibiao.yingyu);
set(handles.edit_wl,'string',chengjibiao.wuli);
set(handles.edit_hx,'string',chengjibiao.huaxue);
set(handles.edit_sw,'string',chengjibiao.shengwu);
set(handles.edit_zf,'string',chengjibiao.zongfen);
% --- Executes on button press in wlpm.
function wlpm_Callback(hObject, eventdata, handles)
% hObject handle to wlpm (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
wuli=str2num(handles.chengjibiao.wuli); %获得每个人的数学分数
[m,n]=size(wuli); %获取人数,为m
wl_pj=sum(wuli)/m; %求得数学的平均分
set(handles.wlpj,'string',num2str(wl_pj)) %显示数学平均分
%%%%%按数学排名
[fenshu mingci]=sort(wuli); %将总分进行排名,获得各人的名次
chengjibiao.xingming=handles.chengjibiao.xingming(mingci,:);
chengjibiao.xuehao=handles.chengjibiao.xuehao(mingci,:);
chengjibiao.yuwen=handles.chengjibiao.yuwen(mingci,:);
chengjibiao.shuxue=handles.chengjibiao.shuxue(mingci,:);
chengjibiao.yingyu=handles.chengjibiao.yingyu(mingci,:);
chengjibiao.wuli=handles.chengjibiao.wuli(mingci,:);
chengjibiao.huaxue=handles.chengjibiao.huaxue(mingci,:);
chengjibiao.shengwu=handles.chengjibiao.shengwu(mingci,:);
chengjibiao.zongfen=handles.chengjibiao.zongfen(mingci,:);
set(handles.edit_xm,'string',chengjibiao.xingming);
set(handles.edit_xh,'string',chengjibiao.xuehao);
set(handles.edit_yw,'string',chengjibiao.yuwen);
set(handles.edit_sx,'string',chengjibiao.shuxue);
set(handles.edit_yy,'string',chengjibiao.yingyu);
set(handles.edit_wl,'string',chengjibiao.wuli);
set(handles.edit_hx,'string',chengjibiao.huaxue);
set(handles.edit_sw,'string',chengjibiao.shengwu);
set(handles.edit_zf,'string',chengjibiao.zongfen);
% --- Executes on button press in hxpm.
function hxpm_Callback(hObject, eventdata, handles)
% hObject handle to hxpm (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
huaxue=str2num(handles.chengjibiao.huaxue); %获得每个人的数学分数
[m,n]=size(huaxue); %获取人数,为m
hx_pj=sum(huaxue)/m; %求得数学的平均分
set(handles.hxpj,'string',num2str(hx_pj)) %显示数学平均分
%%%%%按数学排名
[fenshu mingci]=sort(huaxue); %将总分进行排名,获得各人的名次
chengjibiao.xingming=handles.chengjibiao.xingming(mingci,:);
chengjibiao.xuehao=handles.chengjibiao.xuehao(mingci,:);
chengjibiao.yuwen=handles.chengjibiao.yuwen(mingci,:);
chengjibiao.shuxue=handles.chengjibiao.shuxue(mingci,:);
chengjibiao.yingyu=handles.chengjibiao.yingyu(mingci,:);
chengjibiao.wuli=handles.chengjibiao.wuli(mingci,:);
chengjibiao.huaxue=handles.chengjibiao.huaxue(mingci,:);
chengjibiao.shengwu=handles.chengjibiao.shengwu(mingci,:);
chengjibiao.zongfen=handles.chengjibiao.zongfen(mingci,:);
set(handles.edit_xm,'string',chengjibiao.xingming);
set(handles.edit_xh,'string',chengjibiao.xuehao);
set(handles.edit_yw,'string',chengjibiao.yuwen);
set(handles.edit_sx,'string',chengjibiao.shuxue);
set(handles.edit_yy,'string',chengjibiao.yingyu);
set(handles.edit_wl,'string',chengjibiao.wuli);
set(handles.edit_hx,'string',chengjibiao.huaxue);
set(handles.edit_sw,'string',chengjibiao.shengwu);
set(handles.edit_zf,'string',chengjibiao.zongfen);
% --- Executes on button press in swpm.
function swpm_Callback(hObject, eventdata, handles)
% hObject handle to swpm (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
shengwu=str2num(handles.chengjibiao.shengwu); %获得每个人的数学分数
[m,n]=size(shengwu); %获取人数,为m
sw_pj=sum(shengwu)/m; %求得数学的平均分
set(handles.swpj,'string',num2str(sw_pj)) %显示数学平均分
%%%%%按数学排名
[fenshu mingci]=sort(shengwu); %将总分进行排名,获得各人的名次
chengjibiao.xingming=handles.chengjibiao.xingming(mingci,:);
chengjibiao.xuehao=handles.chengjibiao.xuehao(mingci,:);
chengjibiao.yuwen=handles.chengjibiao.yuwen(mingci,:);
chengjibiao.shuxue=handles.chengjibiao.shuxue(mingci,:);
chengjibiao.yingyu=handles.chengjibiao.yingyu(mingci,:);
chengjibiao.wuli=handles.chengjibiao.wuli(mingci,:);
chengjibiao.huaxue=handles.chengjibiao.huaxue(mingci,:);
chengjibiao.shengwu=handles.chengjibiao.shengwu(mingci,:);
chengjibiao.zongfen=handles.chengjibiao.zongfen(mingci,:);
set(handles.edit_xm,'string',chengjibiao.xingming);
set(handles.edit_xh,'string',chengjibiao.xuehao);
set(handles.edit_yw,'string',chengjibiao.yuwen);
set(handles.edit_sx,'string',chengjibiao.shuxue);
set(handles.edit_yy,'string',chengjibiao.yingyu);
set(handles.edit_wl,'string',chengjibiao.wuli);
set(handles.edit_hx,'string',chengjibiao.huaxue);
set(handles.edit_sw,'string',chengjibiao.shengwu);
set(handles.edit_zf,'string',chengjibiao.zongfen);
% --- Executes during object creation, after setting all properties.
function ywpj_CreateFcn(hObject, eventdata, handles)
% hObject handle to ywpj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function ywpj_Callback(hObject, eventdata, handles)
% hObject handle to ywpj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of ywpj as text
% str2double(get(hObject,'String')) returns contents of ywpj as a double
% --- Executes during object creation, after setting all properties.
function sxpj_CreateFcn(hObject, eventdata, handles)
% hObject handle to sxpj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function sxpj_Callback(hObject, eventdata, handles)
% hObject handle to sxpj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of sxpj as text
% str2double(get(hObject,'String')) returns contents of sxpj as a double
% --- Executes during object creation, after setting all properties.
function yypj_CreateFcn(hObject, eventdata, handles)
% hObject handle to yypj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function yypj_Callback(hObject, eventdata, handles)
% hObject handle to yypj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of yypj as text
% str2double(get(hObject,'String')) returns contents of yypj as a double
% --- Executes during object creation, after setting all properties.
function wlpj_CreateFcn(hObject, eventdata, handles)
% hObject handle to wlpj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function wlpj_Callback(hObject, eventdata, handles)
% hObject handle to wlpj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of wlpj as text
% str2double(get(hObject,'String')) returns contents of wlpj as a double
% --- Executes during object creation, after setting all properties.
function hxpj_CreateFcn(hObject, eventdata, handles)
% hObject handle to hxpj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function hxpj_Callback(hObject, eventdata, handles)
% hObject handle to hxpj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of hxpj as text
% str2double(get(hObject,'String')) returns contents of hxpj as a double
% --- Executes during object creation, after setting all properties.
function swpj_CreateFcn(hObject, eventdata, handles)
% hObject handle to swpj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function swpj_Callback(hObject, eventdata, handles)
% hObject handle to swpj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of swpj as text
% str2double(get(hObject,'String')) returns contents of swpj as a double
% --- Executes on button press in bccj.
function bccj_Callback(hObject, eventdata, handles)
% hObject handle to bccj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
filename=get(handles.baocun,'string');
chengjibiao.xingming=get(handles.edit_xm,'string');
chengjibiao.xuehao=get(handles.edit_xh,'string');
chengjibiao.yuwen=get(handles.edit_yw,'string');
chengjibiao.shuxue=get(handles.edit_sx,'string');
chengjibiao.yingyu=get(handles.edit_yy,'string');
chengjibiao.wuli=get(handles.edit_wl,'string');
chengjibiao.huaxue=get(handles.edit_hx,'string');
chengjibiao.shengwu=get(handles.edit_sw,'string');
%%%计算总分
zongfen=str2num(chengjibiao.yuwen)+str2num(chengjibiao.shuxue)+str2num(chengjibiao.yingyu)+...
str2num(chengjibiao.wuli)+str2num(chengjibiao.huaxue)+str2num(chengjibiao.shengwu);
chengjibiao.zongfen=num2str(zongfen);
set(handles.edit_zf,'string',chengjibiao.zongfen)
save(filename,'chengjibiao') %保存文件
%%%保存成绩表为全局量,方便其他空间调用
handles.chengjibiao=chengjibiao;
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function baocun_CreateFcn(hObject, eventdata, handles)
% hObject handle to baocun (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function baocun_Callback(hObject, eventdata, handles)
% hObject handle to baocun (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of baocun as text
% str2double(get(hObject,'String')) returns contents of baocun as a double
% --- Executes on button press in xhpx.
function xhpx_Callback(hObject, eventdata, handles)
% hObject handle to xhpx (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
xuehao=str2num(handles.chengjibiao.xuehao); %获得每个人的学号
%%%%%按学号排序
[fenshu mingci]=sort(xuehao); %将学号进行排名,获得各人的名次
chengjibiao.xingming=handles.chengjibiao.xingming(mingci,:);
chengjibiao.xuehao=handles.chengjibiao.xuehao(mingci,:);
chengjibiao.yuwen=handles.chengjibiao.yuwen(mingci,:);
chengjibiao.shuxue=handles.chengjibiao.shuxue(mingci,:);
chengjibiao.yingyu=handles.chengjibiao.yingyu(mingci,:);
chengjibiao.wuli=handles.chengjibiao.wuli(mingci,:);
chengjibiao.huaxue=handles.chengjibiao.huaxue(mingci,:);
chengjibiao.shengwu=handles.chengjibiao.shengwu(mingci,:);
chengjibiao.zongfen=handles.chengjibiao.zongfen(mingci,:);
set(handles.edit_xm,'string',chengjibiao.xingming);
set(handles.edit_xh,'string',chengjibiao.xuehao);
set(handles.edit_yw,'string',chengjibiao.yuwen);
set(handles.edit_sx,'string',chengjibiao.shuxue);
set(handles.edit_yy,'string',chengjibiao.yingyu);
set(handles.edit_wl,'string',chengjibiao.wuli);
set(handles.edit_hx,'string',chengjibiao.huaxue);
set(handles.edit_sw,'string',chengjibiao.shengwu);
set(handles.edit_zf,'string',chengjibiao.zongfen);
% --- Executes on button press in xmpx.
function xmpx_Callback(hObject, eventdata, handles)
% hObject handle to xmpx (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
yuwen=str2num(handles.chengjibiao.yuwen); %先获得语文的成绩,防止姓名里有空字符,通过语文成绩的个数来确定人数
[m,n]=size(yuwen); %得到人数(去除掉空的字符)
xingming=handles.chengjibiao.xingming; %获得每个人的姓名
%%%姓名不能转化为number,需要转换成单元数组之后,再进行排序
for iii=1:m
xm{iii}=xingming(iii,:);
end
%%%%%按姓名排序
[fenshu mingci]=sort(xm); %将姓名进行排名,获得各人的名次
chengjibiao.xingming=handles.chengjibiao.xingming(mingci,:);
chengjibiao.xuehao=handles.chengjibiao.xuehao(mingci,:);
chengjibiao.yuwen=handles.chengjibiao.yuwen(mingci,:);
chengjibiao.shuxue=handles.chengjibiao.shuxue(mingci,:);
chengjibiao.yingyu=handles.chengjibiao.yingyu(mingci,:);
chengjibiao.wuli=handles.chengjibiao.wuli(mingci,:);
chengjibiao.huaxue=handles.chengjibiao.huaxue(mingci,:);
chengjibiao.shengwu=handles.chengjibiao.shengwu(mingci,:);
chengjibiao.zongfen=handles.chengjibiao.zongfen(mingci,:);
set(handles.edit_xm,'string',chengjibiao.xingming);
set(handles.edit_xh,'string',chengjibiao.xuehao);
set(handles.edit_yw,'string',chengjibiao.yuwen);
set(handles.edit_sx,'string',chengjibiao.shuxue);
set(handles.edit_yy,'string',chengjibiao.yingyu);
set(handles.edit_wl,'string',chengjibiao.wuli);
set(handles.edit_hx,'string',chengjibiao.huaxue);
set(handles.edit_sw,'string',chengjibiao.shengwu);
set(handles.edit_zf,'string',chengjibiao.zongfen);
% --- Executes on button press in drcj.
function drcj_Callback(hObject, eventdata, handles)
% hObject handle to drcj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[Filename Pathname]=uigetfile({'*.mat','Mat Files(*.mat)'},'请选择文件');
L=length(Filename);
if (L<5)
errordlg('没有选择文件!','文件打开错误') %%%%如果没有选择文件,提示错误信息
return
else
str=[Pathname Filename];
set(handles.xscj,'String',str)
end
Data=load(str); %读入成绩文件
chengjibiao=Data.chengjibiao; %Data是一个结构体,里面的chengjibiao为姓名,学号以及各科成绩等信息
%%%将读入的数据显示在成绩表中
set(handles.edit_xm,'string',chengjibiao.xingming);
set(handles.edit_xh,'string',chengjibiao.xuehao);
set(handles.edit_yw,'string',chengjibiao.yuwen);
set(handles.edit_sx,'string',chengjibiao.shuxue);
set(handles.edit_yy,'string',chengjibiao.yingyu);
set(handles.edit_wl,'string',chengjibiao.wuli);
set(handles.edit_hx,'string',chengjibiao.huaxue);
set(handles.edit_sw,'string',chengjibiao.shengwu);
set(handles.edit_zf,'string',chengjibiao.zongfen);
%%%保存成绩表为全局量,方便其他空间调用
handles.chengjibiao=chengjibiao;
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function xscj_CreateFcn(hObject, eventdata, handles)
% hObject handle to xscj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function xscj_Callback(hObject, eventdata, handles)
% hObject handle to xscj (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of xscj as text
% str2double(get(hObject,'String')) returns contents of xscj as a double
% --- Executes during object creation, after setting all properties.
function edit_zf_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_zf (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit_zf_Callback(hObject, eventdata, handles)
% hObject handle to edit_zf (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_zf as text
% str2double(get(hObject,'String')) returns contents of edit_zf as a double
% --- Executes during object creation, after setting all properties.
function figure1_CreateFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
3 仿真结果
4 参考文献
[1]杨文芳. 基于MATLAB设计学生成绩查询系统[J]. 考试周刊, 2016(75):1.