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

📄 reduction.m

📁 Variable Reduction Testbench通过对变量进行相关性分析来实现减少变量的目的。
💻 M
📖 第 1 页 / 共 3 页
字号:

function varargout = reduction(varargin)

% -------------------------------------------------------------------------
% this code is part of the 'Reduction Testbench' suite
% developed by A. Manganaro, R. Todeschini, A. Ballabio, D. Mauri
% 2006 - Milano Chemometrics and QSAR Research Group
% -------------------------------------------------------------------------
%
%
% REDUCTION M-file for reduction.fig
%      REDUCTION, by itself, creates a new REDUCTION or raises the existing
%      singleton*.
%
%      H = REDUCTION returns the handle to a new REDUCTION or the handle to
%      the existing singleton*.
%
%      REDUCTION('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in REDUCTION.M with the given input arguments.
%
%      REDUCTION('Property','Value',...) creates a new REDUCTION or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before reduction_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to reduction_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% INIT code 
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @reduction_OpeningFcn, ...
                   'gui_OutputFcn',  @reduction_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(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


% --------------------------------------------------------------------


function reduction_OpeningFcn(hObject, eventdata, handles, varargin)
% Executes just before reduction is made visible.
% 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 reduction (see VARARGIN)

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

movegui(handles.reduction_form,'center');

handles.headers_present=0;
handles.data_present=0;
handles.txt_file = ' ';
handles.mat_file = ' ';
set(handles.radio_method_10,'Value',1);

% Update handles structure
guidata(hObject, handles);


% --------------------------------------------------------------------


function varargout = reduction_OutputFcn(hObject, eventdata, handles)
% Outputs from this function are returned to the command line.
% 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;


% --------------------------------------------------------------------


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


% --------------------------------------------------------------------


function save_mat_edit_CreateFcn(hObject, eventdata, handles)
% Executes during object creation, after setting all properties.
% hObject    handle to save_mat_edit (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 save_txt_edit_CreateFcn(hObject, eventdata, handles)
% Executes during object creation, after setting all properties.
% hObject    handle to save_txt_edit (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




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Menu items HANDLERS 
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


function File_Callback(hObject, eventdata, handles)
% hObject    handle to File (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------


function Open_ws_file_Callback(hObject, eventdata, handles)
% hObject    handle to Open_ws_file (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Gets the path and filename from the standard file dialog
[cur_filename,cur_pathname] = uigetfile('*.mat','Open workspace');
handles.cur_file = [cur_pathname cur_filename];

% Loads in the listbox the names of the workspace's variables
set(handles.ws_listbox,'Value',1);
cur_vars = who('-file',handles.cur_file);
set(handles.ws_listbox,'String',cur_vars);

box_strings = get(handles.ws_listbox,'String');
cur_string = box_strings{get(handles.ws_listbox,'Value')};
handles.cur_var = whos('-file',handles.cur_file,cur_string);

set(handles.var_name_text,'String',[handles.cur_var.name ':']);
set(handles.var_dim_text,'String',[num2str(handles.cur_var.size(1)) ' x ' num2str(handles.cur_var.size(2))]);
set(handles.var_size_text,'String',[num2str(handles.cur_var.bytes) ' bytes']);

set(handles.loaded_headers_text,'String','');
handles.headers_present=0;

set(handles.loaded_data_text,'String','');
handles.data_present=0;

% Update handles structure
guidata(hObject, handles);


% --------------------------------------------------------------------


function About_Callback(hObject, eventdata, handles)
% hObject    handle to About (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------


function openAbout_Callback(hObject, eventdata, handles)
% hObject    handle to openAbout (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

about;


% --------------------------------------------------------------------


function exit_menu_Callback(hObject, eventdata, handles)
% hObject    handle to exit_menu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

close(handles.reduction_form);


% --------------------------------------------------------------------


function Settings_menu_Callback(hObject, eventdata, handles)
% hObject    handle to Settings_menu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------


function Preprocessor_menu_Callback(hObject, eventdata, handles)
% hObject    handle to Preprocessor_menu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

cur_status = get(handles.Preprocessor_menu,'Checked');
if strcmp(cur_status,'on')
    set(handles.Preprocessor_menu,'Checked','off');
else
    set(handles.Preprocessor_menu,'Checked','on');
end


% --------------------------------------------------------------------


function Preprocessor2_menu_Callback(hObject, eventdata, handles)
% hObject    handle to Preprocessor2_menu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

cur_status = get(handles.Preprocessor2_menu,'Checked');
if strcmp(cur_status,'on')
    set(handles.Preprocessor2_menu,'Checked','off');
else
    set(handles.Preprocessor2_menu,'Checked','on');
end


% --------------------------------------------------------------------


function logging_menu_Callback(hObject, eventdata, handles)
% hObject    handle to logging_menu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

cur_status = get(handles.logging_menu,'Checked');
if strcmp(cur_status,'on')
    set(handles.logging_menu,'Checked','off');
else
    set(handles.logging_menu,'Checked','on');
end


% --------------------------------------------------------------------


function threshold_menu_Callback(hObject, eventdata, handles)
% hObject    handle to threshold_menu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

thresholds;


% --------------------------------------------------------------------


function Tools_menu_Callback(hObject, eventdata, handles)
% hObject    handle to Tools_menu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------


function Corrstats_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

if (handles.data_present)

    if strcmp(get(handles.Preprocessor_menu,'Checked'),'on')
        check_vars = 'y';
    else
        check_vars = 'n';
    end

    if strcmp(get(handles.Preprocessor2_menu,'Checked'),'on')
        check_missing = 'y';
    else
        check_missing = 'n';
    end

    if (strcmp(check_vars,'y') || strcmp(check_missing,'y'))
        if (handles.headers_present)
            hd = handles.loaded_headers;
        else
            hd = [];
        end
        [proc_ans, proc_data, proc_headers] = preprocess(handles.loaded_data, hd, ...
            check_vars,check_missing, -999);
        if ~isempty(proc_ans)
            handles.loaded_data = proc_data;
            handles.loaded_headers = proc_headers;
            guidata(hObject, handles);
            wb = warning_box(proc_ans);
            waitfor(wb);
        end
    end

    if (get(handles.corrmat_checkbox,'Value') == get(handles.corrmat_checkbox,'Max'))
        data_corrmat = 1;
    else
        data_corrmat = 0;
    end
    
    if (handles.headers_present)
        correlation(handles.loaded_data, handles.loaded_headers,data_corrmat);
    else
        correlation(handles.loaded_data,[],data_corrmat);
    end        
    
else
    warning_box('No data selected');
end


% --------------------------------------------------------------------


function Corrmatrix_Callback(hObject, eventdata, handles)
% hObject    handle to Corrmatrix (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

if (handles.data_present)
    show_correlation_matrix(handles.loaded_data);
else
    warning_box('No data selected');
end


% --------------------------------------------------------------------


function save_corr_mat_menu_Callback(hObject, eventdata, handles)
% hObject    handle to save_corr_mat_menu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


if (handles.data_present)

    if (handles.headers_present)
        hd = handles.loaded_headers;
    else
        hd = [];
    end

⌨️ 快捷键说明

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