西安邮电大学Matlab实验报告

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

西安邮电大学MATLAB及其EDA仿真课内实验报告院(系)名称:电子工程学院学生姓名:张伟杰专业名称:集成电路设计与集成系统班级:1101班时间:2013年12月25日一、实验内容建立基于图形用户界面GUI的学生成绩管理系统,该系统能够实现学生成绩信息的增加、删除、查询、课程成绩统计等功能。二、实验目的通过本实验使学生掌握图形用户界面GUI的操作和设计流程,并通过编写回调函数巩固前期的知识。三、报告正文(一)设计思路主要在学生管理系统中添加三个功能:增加学生目录,删除学生目录,搜索学生目录。三大功能都是基于对本地excel文件的读写访问。流程框图:启动刷新/加载在listbox显示添加删除搜索输入数据(二)设计步骤与设计内容1.在matlab软件中输入guide命令,启动GUI,选择新建空白GUI项目;2.放置控件。放置listbox1~listbox5控件,外观默认设置,String均为空,Tag分别为:Listbox_Number,Listbox_Name,Listbox_Chinese,Listbox_Math,Listbox_English。该系列控件作为学生目录资料的输出面板。放置PushButton控件。PushButton1,颜色设置为粉色,String为Load,Tag为Load,用作加载本地Excel文件;PushButton2,颜色为黄色,String为Add,Tag为Add,用作调出增加学生目录的面板;PushButton3,颜色为蓝色,String为Delete,Tag为Delete,用作调出删除学生目录的面板;PushButton4,颜色为粉色,String为Search,Tag为Search,用作调出搜索学生目录的面板。放置EditText1~6控件,用于提示对应Listbox的显示内容。Srting分别为:StudentsPerformanceManagementSystem,Number,Name,Chinese,Math,English。放置EditText控件作为背景颜色。GUI界面如下:3.保存.fig文件。4.编写回调函数:%Begininitializationcode-DONOTEDITgui_Singleton=1;gui_State=struct('gui_Name',mfilename,...'gui_Singleton',gui_Singleton,...'gui_OpeningFcn',@student_message0_OpeningFcn,...'gui_OutputFcn',@student_message0_OutputFcn,...'gui_LayoutFcn',[],...'gui_Callback',[]);ifnargin&&ischar(varargin{1})gui_State.gui_Callback=str2func(varargin{1});endifnargout[varargout{1:nargout}]=gui_mainfcn(gui_State,varargin{:});elsegui_mainfcn(gui_State,varargin{:});end%Endinitializationcode-DONOTEDIT%---Executesjustbeforestudent_message0ismadevisible.functionstudent_message0_OpeningFcn(hObject,eventdata,handles,varargin)%Thisfunctionhasnooutputargs,seeOutputFcn.%hObjecthandletofigure%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%varargincommandlineargumentstostudent_message0(seeVARARGIN)%Choosedefaultcommandlineoutputforstudent_message0handles.output=hObject;%Updatehandlesstructureguidata(hObject,handles);%UIWAITmakesstudent_message0waitforuserresponse(seeUIRESUME)%uiwait(handles.figure1);[a,xingming]=xlsread('student_message.xls')%读xls文件,电话号码存在a,字符串存在xingminghandles.xingming=xingming(2:end,1)handles.number=aguidata(hObject,handles);set(handles.listbox1,'string',handles.xingming);set(handles.listbox2,'string',num2str(handles.number));首先创建excel文档:系统初始化界面:%---Outputsfromthisfunctionarereturnedtothecommandline.functionvarargout=student_message0_OutputFcn(hObject,eventdata,handles)%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);%hObjecthandletofigure%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Getdefaultcommandlineoutputfromhandlesstructurevarargout{1}=handles.output;%---Executesonselectionchangeinlistbox1.functionlistbox1_Callback(hObject,eventdata,handles)%hObjecthandletolistbox1(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:contents=cellstr(get(hObject,'String'))returnslistbox1contentsascellarray%contents{get(hObject,'Value')}returnsselecteditemfromlistbox1str=get(hObject,'string');val=get(hObject,'Value');NAME=str{val};yes=strcmp(handles.xingming,NAME);%字符串比较[i,j]=find(yes==1);set(handles.listbox2,'Value',i);%---Executesduringobjectcreation,aftersettingallproperties.functionlistbox1_CreateFcn(hObject,eventdata,handles)%hObjecthandletolistbox1(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:listboxcontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end%---Executesonselectionchangeinlistbox2.functionlistbox2_Callback(hObject,eventdata,handles)%hObjecthandletolistbox2(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:contents=cellstr(get(hObject,'String'))returnslistbox2contentsascellarray%contents{get(hObject,'Value')}returnsselecteditemfromlistbox2%---Executesduringobjectcreation,aftersettingallproperties.functionlistbox2_CreateFcn(hObject,eventdata,handles)%hObjecthandletolistbox2(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:listboxcontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end%---Executesonbuttonpressinpushbutton1.functionpushbutton1_Callback(hObject,eventdata,handles)%hObjecthandletopushbutton1(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)prompt={'InputName'};title='InputName';name_cx=inputdlg(prompt,title)yes=strcmp(handles.xingming,name_cx);%字符串比较[i,j]=find(yes==1);set(handles.listbox1,'String',handles.xingming(i,1));set(handles.listbox2,'string',num2str(handles.number(i,1)));实现搜索界面:%---Executesonbuttonpressinpushbutton2.functionpushbutton2_Callback(hObject,eventdata,handl

1 / 9
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功