function varargout = untitled(varargin)
% UNTITLED MATLAB code for untitled.fig
% UNTITLED, by itself, creates a new UNTITLED or raises the existing
% singleton*.
%
% H = UNTITLED returns the handle to a new UNTITLED or the handle to
% the existing singleton*.
%
% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED.M with the given input arguments.
%
% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled_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 untitled
% Last Modified by GUIDE v2.5 02-Jun-2012 12:45:16
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled_OpeningFcn, ...
'gui_OutputFcn', @untitled_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 untitled is made visible.
function untitled_OpeningFcn(hObject, eventdata, handles, varargin)
%全局数据文件
ha=axes('units','normalized','position',[0 0 1 1]);
uistack(ha,'down')
%II=imread('禾木01.bmp');%里面的参数可以是你自己的图片,把名字连同格式写进去就可以了
II=imread('dong1.jpg');
image(II)
colormap gray
set(ha,'handlevisibility','off','visible','off');
%全局数据文件
global dat;
%打开文件夹 路径对话框,显示xls后缀的文件,等待选中
[filename,pathname]=uigetfile('*.xls');
file=[pathname,filename];
%打开存有成绩的excel文件
dat=xlsread('data.xls','','')
%将成绩数据存到handle结构里
handles.chengji=dat
handles.output = hObject;
%保存已经改动的数据结构,这样才能在callbacks动作响应中使用
guidata(hObject, handles);
% 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 untitled (see VARARGIN)
% Choose default command line output for untitled
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled_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 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 popupmenu1
% --- 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
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
%获取下拉框value值popup_sel_index
popup_sel_index = get(handles.popupmenu1, 'Value');
%将成绩数据从handle中提取出来到二维数组chengji中去
ss=num2str(handles.chengji)
chengji=str2num(ss)
%提取成绩数组中1--20号的成绩到一维数组s中去
for n=1:20
s(n)=chengji(n,2)
end
%s行向量变成列向量as,便于显示
as=dsort(s);
%处理成绩数据进行排名
for i=1:20
for j=1:20
if as(i)==s(j);
bb(i)=j;
end
end
end
for i=1:19
kk=i+1;
if as(i)==as(kk)
k=bb(i)-1;
for t=1:k
if as(i)==s(t)
bb(kk)=t;
end
end
end
end
%获取最大值、最小值、平均值 、标准差
mi =min(s);
ma=max(s);
mea=mean(s);
fc=std(s);
for i=1:20%获取最大值对应的学号
if mi==s(i)
mii=i ;
elseif ma==s(i)%获取最小值对应的学号
maa=i ;
end
end
set(handles.text6,'String','');
switch popup_sel_index
case 6%显示原始分
i=1:20;
set(handles.text4,'String',i);
set(handles.text5,'String',s);
set(handles.text6,'String','');
case 1%显示最大值及其学号
set(handles.text5,'String',ma);
set(handles.text4,'String',maa);
case 2%显示最小值及其学号
set(handles.text5,'String',mi);
set(handles.text4,'String',mii);
case 3%显示平均值
set(handles.text4,'String','');
set(handles.text5,'String',mea);
case 4%显示标准差
set(handles.text4,'String','');
set(handles.text5,'String',fc);
case 5%显示成绩排名
set(handles.text5,'String',as);
set(handles.text4,'String',bb);
cc=1:20;
set(handles.text6,'String',cc);
end
% 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)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
axes(handles.axes1);
cla;
ss=num2str(handles.chengji)
chengji=str2num(ss)
for n=1:20
s(n)=chengji(n,2)
end
aa=[0 0 0 0 0];
%为直方图的绘制进行数据累加
for i=1:20
if s(i)<60
aa(1)= aa(1)+1;
elseif s(i)<70
aa(2)= aa(2)+1;
elseif s(i)<80
aa(3)= aa(3)+1;
elseif s(i)<90
aa(4)= aa(4)+1;
else
aa(5)= aa(5)+1;
end
end
x=[50 65 75 85 95];
%绘制直方图函数
bar(x,aa);
% 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)
function 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,'Bac
- 1
- 2
- 3
前往页