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

📄 ida.asv

📁 支持向量机工具箱
💻 ASV
字号:
function varargout = IDA(varargin)
% IDA M-file for IDA.fig
%      IDA, by itself, creates a new IDA or raises the existing
%      singleton*.
%
%      H = IDA returns the handle to a new IDA or the handle to
%      the existing singleton*.
%
%      IDA('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in IDA.M with the given input arguments.
%
%      IDA('Property','Value',...) creates a new IDA or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before IDA_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to IDA_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 IDA

% Last Modified by GUIDE v2.5 02-Jun-2006 11:54:39

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @IDA_OpeningFcn, ...
                   'gui_OutputFcn',  @IDA_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 IDA is made visible.
function IDA_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 IDA (see VARARGIN)

% Choose default command line output for IDA
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = IDA_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)
orig_data = load('iris'); % load input data
model = lda(orig_data,2); % train LDA
ext_data = linproj(orig_data,model); % feature extraction
axes(handles.axes1);cla;
ppatterns(ext_data); % plot ext. da
%pboundary(model);

% --- 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)
% Generate data
axes(handles.axes2);cla;

distrib.Mean = [[5;4] [4;5]]; % mean vectors
distrib.Cov(:,:,1) = [1 0.9; 0.9 1]; % 1st covariance
distrib.Cov(:,:,2) = [1 0.9; 0.9 1]; % 2nd covariance
distrib.Prior = [0.5 0.5]; % Gaussian weights
index = get(handles.popupmenu1, 'Value');
switch index
     case 1
         data = gmmsamp(distrib,100); % sample data
     case  2
         data = gmmsamp(distrib,150);
     case 3    
         data = gmmsamp(distrib,200);
     case 4
         data = gmmsamp(distrib,250);
end        
         
lda_model = lda(data,2); % train LDA
lda_rec = pcarec(data.X,lda_model);
lda_data = linproj(data,lda_model);
pca_model = pca(data.X,1); % train PCA
pca_rec = pcarec(data.X,pca_model);
pca_data = linproj( data,pca_model);

ppatterns(data);
%h1 = plot(lda_rec(1,:),lda_rec(2,:),'r');
%h2 = plot(pca_rec(1,:),pca_rec(2,:),'b');
%legend([h1 h2],'LDA direction','PCA direction');
axes(handles.axes3);cla;title('LDA');
%subplot(2,1,1); title('LDA'); ppatterns(lda_data);
ppatterns(lda_data);
pgauss(mlcgmm(lda_data));
axes(handles.axes3);cla;title('PCA');
%subplot(2,1,2); title('PCA'); ppatterns(pca_data);

 ppatterns(pca_data);
pgauss(mlcgmm(pca_data));
D=struct('data',data,'lda_data',lda_data,'pca_data',pca_data);
set(handles.pushbutton2,'userdata',D);%传递数据,准备后面的函数使用
% --- 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)
D=get(handles.pushbutton2,'userdata');%从pushbtton2中接收数据
data=D.data;lda_data=D.lda_data;
pca_data=D.pca_data;
axes(handles.axes1);cla;

ppatterns(data);

axes(handles.axes2);title('LDA');cla;
%ppatterns(data);
ppatterns(lda_data);
axes(handles.axes3);cla;

pgauss(mlcgmm(lda_data));

axes(handles.axes4);cla;
title('PCA');
ppatterns(pca_data);
axes(handles.axes5);cla;

pgauss(mlcgmm(pca_data));


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

close(gcf);



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


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

% 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


⌨️ 快捷键说明

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