基于matlab的学生成绩分析系统设计
- 格式:doc
- 大小:747.92 KB
- 文档页数:31
基于MATLABGUI的成绩分析系统设计与应用作者:耿爱华魏幼平李春奇陈薪来源:《电脑知识与技术》2020年第25期摘要:随着学生规模和信息量的日益扩大,就需要开发一个实用的成绩分析系统来提高老师们的工作效率。
本着这样的需求设计开发出一款基于MATLAB GUI成绩分析系统,通过读取一份成绩单文件便可以对学生成绩做一个数据处理和细致分析。
该数据分析界面友好、操作方便、交互性强、维护简易,实现了数据的可视化操作,并极大提高了教学办公的效率和效果。
关键词:MATLAB;GUI设计;数据处理;成绩分析中图分类号:TP311 ; ; ; ; ;文献标识码:A文章编号:1009-3044(2020)25-0031-05Abstract: With the increasing of student size and information, it is necessary to develop a practical achievement analysis system to improve the work efficiency of teachers. In line with such requirements to design and develop a performance analysis system based on MATLAB GUI, just by reading a transcript file can do a detailed analysis of student performance. The data analysis interface is friendly, easy to operate, interactive, easy to maintain, the realization of data visualization operation, greatly improve the efficiency and effect of teaching office.Key words: MATLAB; GUI design; data processing; performance analysis1引言吳浩宏[1]在对中职院校学生成绩管理信息系统的研究技术主要涉及Java开发技术的SQL Server 2005数据库开发技术,研究所使用的分析方法是UML面向对象分析方法。
MATLAB 课程成绩管理系统设计一、系统概述MATLAB 课程成绩管理系统是一个用于管理学生成绩的软件系统。
该系统旨在提供一个方便、高效的方式来存储、查询、修改和分析学生成绩。
通过该系统,教师可以轻松地录入学生信息、录入成绩、查看成绩报告、生成成绩单等。
学生可以查询自己的成绩和排名,了解自己的学习情况。
二、系统功能1. 学生信息管理:录入、修改和删除学生信息,包括姓名、学号、班级等。
2. 成绩录入:录入学生的考试成绩、作业成绩、实验成绩等。
3. 成绩查询:根据学生姓名、学号或班级等信息查询学生的成绩。
4. 成绩分析:统计学生的平均分、最高分、最低分等,生成成绩报告和排名。
5. 成绩导出:将学生成绩导出为 Excel 文件,方便其他应用程序使用。
6. 系统设置:设置用户权限、修改密码等。
三、系统设计1. 数据结构设计:使用数据库来存储学生信息和成绩数据,设计相应的表结构,包括学生表、成绩表等。
2. 用户界面设计:使用 MATLAB GUI 设计用户界面,包括菜单栏、工具栏、文本框、按钮等控件。
3. 事件处理:为每个控件添加事件处理函数,实现系统的各项功能。
4. 数据交互:通过 MATLAB 的数据交互功能,实现与数据库的连接和数据操作。
5. 报表生成:使用 MATLAB 的报表生成功能,生成成绩报告和排名报表。
四、系统实现1. 安装 MATLAB 和数据库管理系统(如 MySQL),并配置好相应的环境变量。
2. 创建数据库和表结构,导入学生信息和成绩数据。
3. 使用 MATLAB GUI 设计用户界面,添加控件和事件处理函数。
4. 连接数据库,实现数据交互和操作。
5. 编写代码实现各项功能,并进行测试和调试。
6. 将系统打包成可执行文件,方便用户安装和使用。
有下列xls成绩表要求用matlab设计GUI要求导入xls,能够查询某同学的分数设计运行效果图如下:关键程序:导入数据按钮下的callback函数:function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (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({'*.xls'},'Choose a file');str=[PathName FileName];set(handles.edit1,'string',str);[data,text_data]=xlsread(str);handles.data=data;handles.text=text_data;guidata(hObject, handles);查询按钮下的callback函数function pushbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)str=get(handles.edit3,'string');str_temp=str2num(str);index=find(handles.data(:)==str_temp);[i,j]=ind2sub(size(handles.data),index);str1=handles.data(i,:);str11=[];for ix=1:size(handles.data,2)str11=strcat(str11,num2str(str1(ix)));endset(handles.edit2,'string',str);set(handles.edit4,'string',num2str(str1(2)));set(handles.edit5,'string',num2str(str1(3)));set(handles.edit6,'string',num2str(str1(4)));set(handles.edit7,'string',num2str(str1(5)));set(handles.edit8,'string',num2str(str1(6)));在初始化函数中添加:function student_core_view_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 command line arguments to student_core_view (see VARARGIN)% Choose default command line output for student_core_viewhandles.output = hObject;handles.data=[];handles.text=[];% Update handles structureguidata(hObject, handles);。
XXXXXX大学MATLAB期末论文题目:基于MATLAB实现的学生成绩管理程序作者:QQ52011811学号:XXX指导老师:XXX单位:物理与电子信息工程学院班级:08 级通信工程一班2010年6月目录序言··················································································第03页摘要··················································································第04页第一章··················································································第06页第二章··················································································第08页参考文献··············································································第10页序言MATLAB是一种与数学密切相关的算法语言,是目前在工程界流行最为广泛的计算机语言,也是当今最优秀的科技应用软件之一。
function varargout = gui(varargin)% GUI M-file for gui.fig% GUI, by itself, creates a new GUI or raises the existing% singleton*.%% H = GUI returns the handle to a new GUI or the handle to% the existing singleton*.%% GUI('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in GUI.M with the given input arguments.%% GUI('Property','Value',...) creates a new GUI or raises the% existing singleton*. Starting from the left, property value pairs are % applied to the GUI before gui_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application % stop. All inputs are passed to gui_OpeningFcn via varargin.%% *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 gui% Last Modified by GUIDE v2.5 03-Dec-2014 19:33:07% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ...'gui_Singleton', gui_Singleton, ...'gui_OpeningFcn', @gui_OpeningFcn, ...'gui_OutputFcn', @gui_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{:});elsegui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before gui is made visible.function gui_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 command line arguments to gui (see VARARGIN)% Choose default command line output for guihandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes gui wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = gui_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 structurevarargout{1} = handles.output;% --- Executes on selection change in listbox1.function listbox1_Callback(hObject, eventdata, handles)% hObject handle to listbox1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = cellstr(get(hObject,'String')) returns listbox1 contents as cell array% contents{get(hObject,'Value')} returns selected item from listbox1 % --- Executes during object creation, after setting all properties. function listbox1_CreateFcn(hObject, eventdata, handles)% hObject handle to listbox1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on selection change in listbox2.function listbox2_Callback(hObject, eventdata, handles)% hObject handle to listbox2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = cellstr(get(hObject,'String')) returns listbox2 contents as cell array% contents{get(hObject,'Value')} returns selected item from listbox2% --- Executes during object creation, after setting all properties. function listbox2_CreateFcn(hObject, eventdata, handles)% hObject handle to listbox2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on selection change in listbox3.function listbox3_Callback(hObject, eventdata, handles)% hObject handle to listbox3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = cellstr(get(hObject,'String')) returns listbox3 contents as cell array% contents{get(hObject,'Value')} returns selected item from listbox3 % --- Executes during object creation, after setting all properties. function listbox3_CreateFcn(hObject, eventdata, handles)% hObject handle to listbox3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on selection change in listbox4.function listbox4_Callback(hObject, eventdata, handles)% hObject handle to listbox4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = cellstr(get(hObject,'String')) returns listbox4 contents as cell array% contents{get(hObject,'Value')} returns selected item from listbox4 % --- Executes during object creation, after setting all properties. function listbox4_CreateFcn(hObject, eventdata, handles)% hObject handle to listbox4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows.% See ISPC and COMPUTER.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)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)[a,name]=xlsread('student.xlsx');handles.ID=a(:,1);handles.English=a(:,2);handles.Math=a(:,3);=name(2:end,1);guidata(hObject,handles);set(handles.listbox1,'string',);set(handles.listbox2,'string',handles.ID);set(handles.listbox3,'string',handles.English);set(handles.listbox4,'string',handles.Math);guidata(hObject,handles);% --- Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)button=questdlg('ÊÇ·ñÈ·ÈϹرÕ','¹Ø±ÕÈ·ÈÏ','ÊÇ','·ñ','ÊÇ');if strcmp(button,'ÊÇ')closeelsereturn;end[a,name]=xlsread('student.xlsx');guidata(hObject,handles);set(handles.edit1,'string',handles.guanbi);function edit1_Callback(hObject, eventdata, handles)% hObject handle to edit1 (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 edit1 as text% str2double(get(hObject,'String')) returns contents of edit1 as a double% --- Executes during object creation, after setting all properties. function edit1_CreateFcn(hObject, eventdata, handles)% hObject handle to edit1 (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 && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunction edit2_Callback(hObject, eventdata, handles)% hObject handle to edit2 (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 edit2 as text% str2double(get(hObject,'String')) returns contents of edit2 as a double% --- Executes during object creation, after setting all properties. function edit2_CreateFcn(hObject, eventdata, handles)% hObject handle to edit2 (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 && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)prompt={'input name '};title='input name';name=inputdlg(prompt,title);i=strcmp(,name);[h,l]=find(i==1);set(handles.listbox1,'string',(h,l));set(handles.listbox2,'string',handles.ID(h,l));set(handles.listbox3,'string',handles.English(h,l));set(handles.listbox4,'string',handles.Math(h,l));% --- Executes on selection change in listbox5.function listbox5_Callback(hObject, eventdata, handles)% hObject handle to listbox5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = cellstr(get(hObject,'String')) returns listbox5 contents as cell array% contents{get(hObject,'Value')} returns selected item from listbox5 % --- Executes during object creation, after setting all properties. function listbox5_CreateFcn(hObject, eventdata, handles)% hObject handle to listbox5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on selection change in listbox6.function listbox6_Callback(hObject, eventdata, handles)% hObject handle to listbox6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = cellstr(get(hObject,'String')) returns listbox6 contents as cell array% contents{get(hObject,'Value')} returns selected item from listbox6 % --- Executes during object creation, after setting all properties. function listbox6_CreateFcn(hObject, eventdata, handles)% hObject handle to listbox6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on selection change in listbox7.function listbox7_Callback(hObject, eventdata, handles)% hObject handle to listbox7 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = cellstr(get(hObject,'String')) returns listbox7 contents as cell array% contents{get(hObject,'Value')} returns selected item from listbox7 % --- Executes during object creation, after setting all properties. function listbox7_CreateFcn(hObject, eventdata, handles)% hObject handle to listbox7 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on selection change in listbox8.function listbox8_Callback(hObject, eventdata, handles)% hObject handle to listbox8 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = cellstr(get(hObject,'String')) returns listbox8 contents as cell array% contents{get(hObject,'Value')} returns selected item from listbox8 % --- Executes during object creation, after setting all properties. function listbox8_CreateFcn(hObject, eventdata, handles)% hObject handle to listbox8 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on selection change in listbox9.function listbox9_Callback(hObject, eventdata, handles)% hObject handle to listbox9 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = cellstr(get(hObject,'String')) returns listbox9 contents as cell array% contents{get(hObject,'Value')} returns selected item from listbox9 % --- Executes during object creation, after setting all properties. function listbox9_CreateFcn(hObject, eventdata, handles)% hObject handle to listbox9 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: listbox controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunction edit3_Callback(hObject, eventdata, handles)% hObject handle to edit3 (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 edit3 as text% str2double(get(hObject,'String')) returns contents of edit3 as a double% --- Executes during object creation, after setting all properties. function edit3_CreateFcn(hObject, eventdata, handles)% hObject handle to edit3 (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 && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunction edit4_Callback(hObject, eventdata, handles)% hObject handle to edit4 (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 edit4 as text% str2double(get(hObject,'String')) returns contents of edit4 as a double% --- Executes during object creation, after setting all properties. function edit4_CreateFcn(hObject, eventdata, handles)% hObject handle to edit4 (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 && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on button press in pushbutton4.function pushbutton4_Callback(hObject, eventdata, handles)% hObject handle to pushbutton4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)prompt={'delete name'};title='delete name';name= inputdlg(prompt,title);i=strcmp(,name);[row,col]=find(i==1);(row,:)=[];handles.ID(row,:)=[];handles.English(row,:)=[];handles.Math(row,:)=[];set(handles.listbox1,'string',);set(handles.listbox2,'string',handles.ID);set(handles.listbox3,'string',handles.English);set(handles.listbox4,'string',handles.Math);x=' ';xlswrite('student.xlsx',x,'A2:Z100');xlswrite('student.xlsx',,'Sheet1','A2');xlswrite('student.xlsx',handles.ID,'Sheet1','B2');xlswrite('student.xlsx',handles.English,'Sheet1','C2');xlswrite('student.xlsx',handles.Math,'Sheet1','D2');% --- Executes on button press in pushbutton5.function pushbutton5_Callback(hObject, eventdata, handles)% hObject handle to pushbutton5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)prompt={'name','ID','English','Math'};title='new student';lines=[1 1 1 1];answer=inputdlg(prompt,title,lines);n = length();{n+1,1}=answer{1,1};handles.ID(n+1,1)=str2num(answer{2,1});handles.English(n+1,1)=str2num(answer{3,1});handles.Math(n+1,1)=str2num(answer{4,1});guidata(hObject,handles);set(handles.listbox1,'string',);set(handles.listbox2,'string',handles.ID);set(handles.listbox3,'string',handles.English);set(handles.listbox4,'string',handles.Math);x=' ';xlswrite('student.xlsx',x,'A2:Z100');xlswrite('student.xlsx',,'Sheet1','A2');xlswrite('student.xlsx',handles.ID,'Sheet1','B2');xlswrite('student.xlsx',handles.English,'Sheet1','C2');xlswrite('student.xlsx',handles.Math,'Sheet1','D2');function edit5_Callback(hObject, eventdata, handles)% hObject handle to edit5 (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 edit5 as text% str2double(get(hObject,'String')) returns contents of edit5 as a double% --- Executes during object creation, after setting all properties. function edit5_CreateFcn(hObject, eventdata, handles)% hObject handle to edit5 (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 && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunction edit6_Callback(hObject, eventdata, handles)% hObject handle to edit6 (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 edit6 as text% str2double(get(hObject,'String')) returns contents of edit6 as a double% --- Executes during object creation, after setting all properties. function edit6_CreateFcn(hObject, eventdata, handles)% hObject handle to edit6 (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 && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunction edit7_Callback(hObject, eventdata, handles)% hObject handle to edit7 (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 edit7 as text% str2double(get(hObject,'String')) returns contents of edit7 as a double% --- Executes during object creation, after setting all properties. function edit7_CreateFcn(hObject, eventdata, handles)% hObject handle to edit7 (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 && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunction edit8_Callback(hObject, eventdata, handles)% hObject handle to edit8 (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 edit8 as text% str2double(get(hObject,'String')) returns contents of edit8 as adouble% --- Executes during object creation, after setting all properties. function edit8_CreateFcn(hObject, eventdata, handles)% hObject handle to edit8 (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 && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunction edit9_Callback(hObject, eventdata, handles)% hObject handle to edit9 (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 edit9 as text% str2double(get(hObject,'String')) returns contents of edit9 as a double% --- Executes during object creation, after setting all properties. function edit9_CreateFcn(hObject, eventdata, handles)% hObject handle to edit9 (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 && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on selection change in popupmenu1.function popupmenu1_Callback(hObject, eventdata, handles)% hObject handle to popupmenu1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array% contents{get(hObject,'Value')} returns selected item from popupmenu1str=get(hObject,'String');val=get(hObject,'Value');switch str{val};case'English'handles.current_data=handles.English;bar(handles.English);case'Math'handles.current_data=handles.Math;bar(handles.Math);endguidata(hObject,handles);% --- Executes during object creation, after setting all properties. function popupmenu1_CreateFcn(hObject, eventdata, handles)% hObject handle to popupmenu1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end。
很多同学不愿手动按计算器计算学分绩,如果他们有excel版的成绩单,并且安装了Matlab,那么利用下面的代码就可以计算出100满分制和4.0满分制算法下的学分绩了。
其中100分满分制下的成绩x对应的4.0满分制下的成绩为
4−3∗(100−x)2,x≥60
0, x<60
新建一个M文件,复制下面的代码:
clear all;
close all;
clc;
NUM=xlsread('record.xlsx');
[n,~]=size(NUM);
cre=0;
s1=0;
s2=0;
for i=1:n
if(~isnan(NUM(i,2)))
cre=cre+NUM(i,1);
s1=s1+NUM(i,2).*NUM(i,1);
if(NUM(i,2)>=60)
s2=s2+(4-3*(100-NUM(i,2)).^2/1600).*NUM(i,1);
end
end
end
g1=s1/cre;
g2=s2/cre;
disp(['the gpa in 100 is ',num2str(g1)]);
disp(['the gpa in 4.0 is ',num2str(g2)]);
clear all;
在M文件所在文件夹中,新建一个record.xlsx文件,第一列存储课程的学分,第二列存储课程的成绩(成绩一列中允许出现“通过”、“优秀”等文字):
运行M文件,即可查看结果:
顺祝每位同学都能在大学取得满意的成绩,以内心的阳光驱散生活中的雾霾。
E23 ▼ A BCD EnglishIDnam e00993753874366415 6 9 3 53 8436 43504789548354664 4687775582 56 44585666644 5 5 6 66 4謹s s粋壽蠶鬻SIFil* Ueit Sal?A J - ■a •F nt '33 a ■□为function pushbutt on 1..Callback (hObject, ev&nt data, handles)□ % hObject handle to pushbutt on 1 (see GCBO)% event data reserved - to be defined in a future version of MATLAB% handles structure with handles and user d^ta (see GUIDATA)[ij name]^xlsreadf student ・ xlsx");handles. ID=a(:j 1);handles・ English=a(:^ 2):handles. Math=a(:, 3):handles・ najne=name (2: end^ 1);guidataChObject, handles):set (handles, listboxU ' st ring\ handles. name);set (handles. Iistbox2, ' strmg\ handles. ID):set (handles. Iistbox3,' string7,handles.English):set (handles, listbox^ r string75 handles. Nath);guidata(hObject, handles):function 卩ushbutton2..Callback<hObject, eventdata3 handles)% hObject handle to pu.shbutton.2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) button=Questdlc(,是否确认关闭’,’关闭确认',’是',’否',’是'):if strcmp (button,'是’) closeelseret urn;end[a^name] =xlsread(,student .xlsx'):guidata(hObject, handles):set (handles, edit 1, string handles, guanbi):UKDUUlPb UXl UUllUIl piDAb XII pU^XlUUL I. UIl J.耳function pushbutton3..Callbaclc (hObjectj event data^ handles)申%kObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) prcanpt={ input name }: t itle=' input name";najr.e= input dig (prompt, title);i=strcmp (handles・ nanej nanie);[t»j l]=find(i=l):set (handles, listb0x1$ * string,s (hj 1)):set (handles. Iistbox2,' string', handles. ID(h, 1));set (handles. Iistbox3s* st ring *, handl es. Engli sh (h, 1)):set (handles, listbox^ ' st ring \ handles. Nath (h^ 1)):Sfunct i on pushbutton4..Cal l*back (hObject^ event dat① handles)% hObject handle to pushbutton4 (see GCBO)% event data reserved - to be defined in a future version of KATLAB -% handles structure with handles and user da^a (see GUIDATA)prompt = V delete name'}:■title=* delete name* :nane= inputdlg(prompttitle);i=5trcmp (handles.naniE, name):[row, ^ol]=find(i==l);handles.Tiame(row^ :)=[]:handles. ID (rov, :)=[]:handles.Eng 1 ish(r cvr, :) = []:1 iaiidles.Math(ro:)=[].set(handles・ Listboxl, ' string*, handles・ name):set (handles. list'box2J J string5, handles. ID):set (handles・ Listbox3, ' st ring*, handles・ English);set (handles. Listbox^ J string53 handles. Math);•9x= ;xlswrite C student.xlsx,, x』^2:2100"):xlswrit e (' student, xlsx7, handles・ name, * Sheet 1?, A2?);xlswrit e C student. X I SK*, handles・ ID』'Sheet 1'』'):xlswrite C student.xlsx,, handles. English,J Sheet 1:,' C2‘ );・xlswrite C studerrt.xlsx*, handles・ Math, Sheet ' D2‘ ):function pushbut t on5.. C a 1 lb ack (hObject, event da: handles) % hObject handle t o pushbut t on5 (see GCBO)prompt= {' najne\ 'ID' J English',' Hath'}: title= new student' : lines=[1 1 1 1]:answer=inputdlg(prompt,ti11e, lines): n = length (handles, rtajue): handl e s. name {n+1, l}=ans'wer {1, 1}; handles. ID (n+1 j 1) =?.txZxWB (answer {2, 1});handles.English(n+1, 1) = str2nuHi(answer {3^ 1}): handles. Math(n*+l, l)=str2nuni(answer {4, 1});gui dat a (hOb j e ct, handl e s):set (handles ・ listboxl, ' string", handles, name): set (handles ・ lis±box2s ' string 7、handles. ID); set (handles, list box 3,' st ring *, handles. English): (handles, listbox!, stxing ,, handles. Math). 99x= :xlsvrite(, st udent. xlsx \ x, ? A2: Z100*): xlsvrite (' st udent ・ xLsx'」handles ・nam 巴,'Sheet T , A2): xlsvrite (' student ・ xlsx ,t , handles ・ ID,' Sheet TB?'); xlswr ite (' st udent ・ xlsx ? j handles .English 」7 Sheet 17 j ? C2'); xlswrite (r st udent. x 丄 sx\handles .Math,' iheet V ,' DZ"):for.ction pcpupnenul .Callback (hObiect. eventdata, handles) E% l.Object handle to popupnenul (see GCEO)% cvontdats rosorvod - to bo dofinod in s future vorsion of MATLA3-% handles structure wilh handles and user data (see GUIDATA)% Eints: coni ents = cellstr (gel QiObject,J String*)) returns popupnenul cont ent 3 as cell array % cont onto {got (hCbjoct., 7 Valuo^ ) } returns soloct cd item from popupnonul st i=get (hObject, String') val=get (hObject,' Value*);switch stc Ival);caffe English'handles ・ curr ent _ dat a=handle s .English: bar(handles ・English);cac ' Math*handle?・ current_d^t azhindlec ・ Math :bar (handles. Hath)encgaddata (hObjcctjhandles);S% eve nt data reserved. - to be defined in a future version of MATLAB% handles structure vith handles and user data(see GUIDATA)04姓名学号英语数学杭讨A104/>454104 108109527894455855666666644V847778795554882355466644699933755338873443366644V V Viro83604033学生成绩管理系统delete .姓名学号5069993375sa3oe7w33666":?瓷;:"需工.益input naae 匸]|口J区] input name成绩统计绘图关闭[OK ] [ 8耐1 ]英语数学人1088469o45□叵区是否确认关讯ILH 〕d)nev stu•・•匚| j区)5069993375533887344336664478608477787955548523554666449816学生成绩管理系统138.8SB73?「er-.-_3lIR44.X名n奄兰r)«*4l今rGw囲ET«%H伊色。
西安邮电大学MATLAB及其EDA仿真课内实验报告院(系)名称:电子工程学院姓名:生学李豪名专业称:集成电路设计与集成系统:级班班1202:时间日月2013年1220一、实验内容建立基于图形用户界面GUI的学生成绩管理系统,该系统能够实现学生成绩信息的增加、删除、查询(查询某门课所有学生的成绩并显示排名,查询某个学生的各科成绩并显示排名)、课程成绩统计最高分、最低分、平均分、方差、并显示相应的排名;绘制柱状图、条形图、饼状图、正太分布曲线等功能。
二、实验目的通过本实验使学生掌握图形用户界面GUI的操作和设计流程,并通过编写回调函数巩固前期的知识。
三、报告正文(一)设计思路功绘统单能图计科菜菜成成单单绩绩显示模块成排姓学名绩名号设计步骤与设计内容(二)guideGUI1.启动,命令窗口中输入颜色设置为灰色,edit14,,2.放置控件。
先放置一个Edit Texttag名称设为GUI的功能;设置为‘学生成绩管理系统'String,该控件的功能是显示该,edit4tag再放置五个Edit Text,名称分别设为edit1、edit2、edit3、、edit13、颜色均设置为淡蓝色,String分别设置为‘姓名'其他'、‘成绩\、‘学号'的标题;再放置四‘成绩类型',这些控件的功能作为下面listbox、‘排名',颜色均paiming、xuehao 、grade、名称分别设为个listbox, tagxingming,这些该控件的功能是分别显示对应学生String'设置为‘设置淡蓝色,、名称分别设为再放置五个的姓名、学号、成绩、排名;Edit Text,tagedit7专'String,颜色均设置为淡蓝色,、edit9、edit10edit11 分别设置为、edit8,该控件的功能是显示个人对应的科‘物理',,,业‘‘数学'‘英语'‘体育',颜色设置为灰色,该控件的功axes1名称设为tag,目;再放置一个Axes 能是显示绘制的图; 3.4.保存.fig文件5.编写.m文件,这部分要详细叙述每个子函数的编写思路,每条语句后面要给出注释说明该语句的功能;只需要附上自己编写的回调函数部分,其他系统自动生成的不需要放入报告中。
MATLAB课程实践报告——关于平均学分、绩点的计算****: ***授课班号: 244501学院:计算机与信息学院组长:陈强(1062310211)组员:冯开蕾(1062310201)沈浩东(1062310323)前言学分,是用于计算学生学习程度的一种计量单位,按学期计算,每门课程及实践环节的具体学分数以专业教学计划的标准为准。
例如像我们学校,挂科后重修,需要按学分收费。
只有总学分积累到专业培训计划的要求后才能毕业,而要拿到学士学位则需要绩点高于专业要求。
学分与绩点,是每位大学生所关心的重要指标之一,很多同学辛苦学习,早出晚归,不断的奔波于教室、图书馆、食堂、寝室之间,为的就是能够考个好成绩,取得好的绩点。
然而在平时我们计算学分与绩点的时候,大都只能用计算器一个一个数据的输入,其过程繁琐麻烦,又容易出错。
为此,我们小组通过讨论,决定了我们研究的课题:运用所学的MATLAB知识,来实现平均学分、绩点的计算这个课题的研究。
一、前期准备1、基础知识的学习,积累课题所需要的知识点。
2、去图书馆借阅相关资料的书籍,学习GUI用户界面设计,归一化二阶系的阶跃统响应曲线绘制。
3、小组分工:冯开蕾主要负责前期准备,以及基本程序框架的搭建;陈强主要负责任务的分配以及对整个程序的处理、调试、运行;沈浩东主要负责论文的编写;二、、程序的编写开始搭建程序的结构1、界面设计:采用GUI程序进行设计,直接用程序语言生成可视化控件(而非利用FIG窗口产生控件);主要是通过Set、 uimenu、 text、 get、 uicontrol 等可视化窗口处理函数,生产基本界面,设置句柄,来实现程序所需的各个功能。
在操作中,我们感受到了句柄就好像C语言中的指针,方便巧妙的实现了各个功能模块之间的连接。
2、成绩导入程序设计;主要是运用了load函数,来载入TXT文件中的成绩,学分等数据。
初始设置:global z score a,TXT文件的调用score(i,j),这样就可以直接得到TXT文件中第i行与第j列的数据;之后根据我们的需求,对其进行处理;3、根据我们学校实际的绩点计算方式平均绩点算子的程序设计:绩点是根据成绩给出的,另外单科学分乘以成绩的绩点,然后把各科的结果加起来除以总学分得到的结果就是平均学分绩点,算子如下for k=1:length(score(:,1));%for循环,依次获取每行的数据;xf=xf+score(k,1);%总学分计算zf=zf+score(k,4).*score(k,1);%总绩点计算jf=zf./xf;%平均绩点计算4、输出口学分与绩点显示的程序设计;在计算得到学分与绩点以后,设置句柄,通过调用set语句,把所得的结果显示在可视化窗口中;5、成绩显示网格添加与显示;调用TXT文件,将成绩放在一个数组中,并设置句柄,直接利用画图函数plot函数,画出以成绩为纵坐标的折线图;在显示得到成绩窗口后发现无法直观的看书各科目的成绩,于是引入了grid on函数,产生网格,我们就可以直观地看出成绩了;三、源程序clf resetglobal z score a%·ÂÕÕ¹éÒ»»¯¶þ½×ϵͳµÄ½×Ô¾ÏìÓ¦ÇúÏßH=axes('unit','normalized','position',[0,0,1,1,],'visible','off');set(gcf,'currentaxes',H);str='\fontname{¿¬Ìå}»¶Ó-ʹÓúӺ£´óѧѧ·Ö¼ÆËãϵͳ£¡';set(gcf,'defaultuicontrolunits','normalized');set(gcf,'defaultuicontrolfontsize',11);set(gcf,'defaultuicontrolhorizontal','left');set(gcf,'menubar','none');str1='ѧ·Ö¼ÆËãϵͳ';set(gcf,'name',str1,'numbertitle','off');cg=uimenu(gcf,'label','Îļþ£¨&F£©');cn=uimenu(gcf,'label','¸¨Öú¹¦ÄÜ£¨&E£©');ch=uimenu(gcf,'label','°ïÖú(&H£©');uimenu(ch,'label','ÏÔʾµ±Ç°´¦ÀíÎļþµÄλÖÃ(&L)',...'callback','set(he1,''string'',z)');uimenu(cg,'label','´ò¿ªÎļþ','callback',...'[str11,str12]=uigetfile({''*.*''});a=[str12,str11];z=a;set(he1,''str ing'',a);')uimenu(cg,'label','Í˳öϵͳ','callback','close;clear');uimenu(cn,'label','Ìí¼ÓMº¯Êýµ½¹¤³Ì','callback','edit');text(0.12,0.93,str,'fontsize',13);hg=get(H,'parent');set(hg,'unit','normalized','position',[0.1,0.2,0.7,0.4]);h_axes=axes('parent',hg,...'unit','normalized','position',[0.1,0.15,0.55,0.7],...'xlim',[0 100],'ylim',[0 100],'fontsize',8);h_text1=uicontrol(hg,'style','text',...'unit','normalized','position',[0.67,0.73,0.25,0.07],...'horizontal','left','string','ÇëÔÚÏ·½ÊäÈëÒª´¦ÀíÊý¾ÝµÄ·¾¶:','fontsiz e',10);hp1=uicontrol(hg,'style','push',...'unit','normalized','position',[0.67,0.30,0.12,0.15],...'string','grid on','callback','grid on');hp2=uicontrol(hg,'style','push',...'unit','normalized','position',[0.67,0.15,0.12,0.15],...'string','grid off','callback','grid off');hp3=uicontrol(hg,'style','push',...'unit','normalized','position',[0.67,0.45,0.12,0.15],...'string','¼ÆËãѧ·Ö','callback',[...'score=load(z);',...'zf=0;xf=0;',...'for k=1:length(score(:,1));',...'xf=xf+score(k,1);end;',...'set(he2,''string'',[''ѧ·Ö£º'',num2str(xf)]);'...]);hp4=uicontrol(hg,'style','push',...'unit','normalized','position',[0.80,0.30,0.12,0.15],...'string','¼ÆË㼨µã','callback',[...'score=load(z);',...'zf=0;xf=0;',...'for k=1:length(score(:,1));',...'xf=xf+score(k,1);zf=zf+score(k,4).*score(k,1);end;',...'jf=zf./xf;',...'set(he2,''string'',[''¼¨µã£º'',num2str(jf)]);'...]);hp5=uicontrol(hg,'style','push',...'unit','normalized','position',[0.80,0.15,0.12,0.15],...'string','ÏÔʾ³É¼¨','callback',['score=load(z);'...'t=1:1:length(score(:,2));',...'h_line=plot(t,score(:,2));']);he1=uicontrol(hg,'style','edit',...'unit','normalized',...'position',[0.67,0.65,0.25,0.07],...'horizontal','left',...'callback','z=get(gcbo,''string'');'...);he2=uicontrol(hg,'style','edit',...'unit','normalized',...'string','Êä³ö¿Ú',...'position',[0.80,0.45,0.12,0.15],...'horizontal','left');四、结果展示1、程序主窗口2、打开需要计算的TXT文件3、数据所存路径的显示:4、计算学分、绩点的展示4、显示成绩以及格点五、收获与总结通过这次做基于MATLAB的项目设计,我们学到了很多。