⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svm_demo4.m

📁 具有图形操作界面的支持向量机多类分类实验系统.全部用Matlab实现,可以实现多种分类识别. 这是本人的毕业设计的附属程序
💻 M
字号:
function varargout = SVM_DEMO4(varargin)
% SVM_DEMO4 M-file for SVM_DEMO4.fig
%      SVM_DEMO4, by itself, creates a new SVM_DEMO4 or raises the existing
%      singleton*.
%
%      H = SVM_DEMO4 returns the handle to a new SVM_DEMO4 or the handle to
%      the existing singleton*.
%
%      SVM_DEMO4('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in SVM_DEMO4.M with the given input arguments.
%
%      SVM_DEMO4('Property','Value',...) creates a new SVM_DEMO4 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before SVM_DEMO4_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to SVM_DEMO4_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

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help SVM_DEMO4

% Last Modified by GUIDE v2.5 26-Apr-2006 15:27:05
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @SVM_DEMO4_OpeningFcn, ...
                   'gui_OutputFcn',  @SVM_DEMO4_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 SVM_DEMO4 is made visible.
function SVM_DEMO4_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 SVM_DEMO4 (see VARARGIN)

data=struct(...
     'pushbutton1', handles.pushbutton1,... %'bt_close',hbt_close,...
     'pushbutton2', handles.pushbutton2,... %'bt_train',hbt_train,...
     'pushbutton3', handles.pushbutton3,... %'bt_reset',hbt_reset,... 'pushbutton3', handles.pushbutton3
     'pushbutton4', handles.pushbutton4,...% 'bt_info',hbt_info,...pushbutton4
     'pushbutton5', handles.pushbutton5,... %'bt_close',hbt_close,...
     'pushbutton6', handles.pushbutton6,... %'bt_train',hbt_train,...
     'pushbutton7', handles.pushbutton7,... %'bt_reset',hbt_reset,... 'pushbutton3', handles.pushbutton3
     'pushbutton8', handles.pushbutton8,...% 'bt_info',hbt_info,...pushbut
     'popupmenu1', handles.popupmenu1,...%'pu_algo',hpu_algo,...
     'popupmenu2', handles.popupmenu2,...% 'pu_kernel', hpu_kernel,...
     'popupmenu3', handles.popupmenu3,...% 'pu_kernel', hpu_kernel,...
     'edit1', handles.edit1,...% 'ed_arg', hed_arg,...
     'edit2', handles.edit2,...% 'ed_param', hed_param,...
     'axes1', handles.axes1,...%'axes',haxes,...
     'axes2', handles.axes2,...  %'xb_background',hxb_background);  
     'axes3', handles.axes3);  %'xb_background',hxb_background); 

   set(gcf ,'UserData',data );
   %resetB(gcf);
   set(gcf,'Visible','on');
   drawnow;
% Choose default command line output for SVM_DEMO4
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes SVM_DEMO4 wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = SVM_DEMO4_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 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)
h = waitbar(1,'Please wait...');
for i=1:500, % computation here %
waitbar(i/100)
end
close(h) 
data=get( gcf,'UserData');%data.pushbutton4=handles.pushbutton4;
[name,path]=uigetfile('*.mat','Open file');
 if name~=0,
      file.pathname=strcat(path,name); 
      file.path=path;
      file.name=name;
 %    if checkdat(file.pathname,DATA_IDENT,2,[0 0])==1,  
    %   Addpath('G:/Matlab_EXP/stprtool/data');
 if check2ddata( file.pathname )  % check2ddata( file.pathname ),
       set(data.pushbutton1,'UserData',file);
      cla;
       data=loadsets2(gcf);         %   装载结构型数据
  % data = loadsetsCoL(gcf);    %   若要装载列数据,则请将此行代替上面一行.which loadsetsCoL(gcf)
    %  data.data1=data;
      set(gcf,'UserData',data);
      set(handles.edit1,'String','The Data has been Loaded !');
   %   resetB(gcf);
      else
         errordlg('This file does not contain required data.','Bad file','modal'); 
      end
   end

% --- 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)
n=3;
createdata('finite',n,'created',gcf);


% --- 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) 
axes(handles.axes1);
cla;
axes(handles.axes2);cla;
clear;clc;

% --- 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)

resetB(gcf);
% --- 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)
handles.pushbutton5=get(hObject,'Value');
data=get(gcf,'userdata');
 X=data.data1.X;  Y=data.data1.Y; 
% x1ran=data.data1.x1ran; x2ran=data.data1.x2ran;

axes(handles.axes2);cla;

plotdata2(X, Y)
%[X ,Y ,x1ran, x2ran]=plotdata2();
%plotdataGriph;handles.pushbutton1
%H.X=X;H.Y=Y;%H.R1=x1ran;H.R2=x1ran;
%set(gcf,'userdata',H);

% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
axes(handles.axes1);
data=get(gcf,'userdata');
X=data.data1.X;
Y=data.data1.Y;
x1ran=data.data1.x1ran;
x2ran=data.data1.x2ran;
val = get(handles.popupmenu1,'Value');
switch val
case 1
    cla;
[X,Y,net,T]=plotsvGriphB(X,Y, x1ran, x2ran);
case 2
    cla;
[X,Y,net,T]=plotsvGriph2B(X,Y, x1ran, x2ran);
case 3
    cla; 
[X,Y,net, T]=plotsvGriph3B(X,Y, x1ran, x2ran);
case 4
    cla;
[X,Y,net, T]=plotsvGriph4B(X,Y, x1ran, x2ran);
case 5
    cla;
[X,Y,net, T]=plotsvGriph5B(X,Y, x1ran, x2ran);
end
data.T=T;
set(gcf,'userdata',data);
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton7 (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 pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
data=get(gcf,'userdata');
T=data.T; 
T1=num2str(T);
Text=['训练所用时间   ' T1];

set(handles.edit1,'String',Text);
axes(handles.axes3);
bar(0.5,T);
axis([0 1 0 1]);
hold off
% --- 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 = 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
handles.popupmenu1=get(hObject,'Value');

% Hint: popupmenu 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


% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu2


% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in popupmenu3.
function popupmenu3_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu3 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu3


% --- Executes during object creation, after setting all properties.
function popupmenu3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu3 (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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



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
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes during object creation, after setting all properties.function text2_CreateFcn(hObject, eventdata, handles)% hObject    handle to text2 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% --- Executes during object creation, after setting all properties.function pushbutton1_CreateFcn(hObject, eventdata, handles)% hObject    handle to pushbutton1 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -