📄 iplsgui.m
字号:
function varargout = iplsGUI(varargin)
% IPLSGUI M-file for iplsGUI.fig
% IPLSGUI, by itself, creates a new IPLSGUI or raises the existing
% singleton*.
%
% H = IPLSGUI returns the handle to a new IPLSGUI or the handle to
% the existing singleton*.
%
% IPLSGUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in IPLSGUI.M with the given input arguments.
%
% IPLSGUI('Property','Value',...) creates a new IPLSGUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before iplsGUI_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to iplsGUI_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 iplsGUI
% Last Modified by GUIDE v2.5 04-Apr-2006 15:19:21
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @iplsGUI_OpeningFcn, ...
'gui_OutputFcn', @iplsGUI_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 iplsGUI is made visible.
function iplsGUI_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 iplsGUI (see VARARGIN)
% Choose default command line output for iplsGUI
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% Populate the listbox
%set(handles.ListMatrix,'Value',[])
% UIWAIT makes iplsGUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = iplsGUI_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;
vars = evalin('base','who');
set(handles.Ymatrix,'String',vars)
set(handles.ListAxis,'String',vars)
set(handles.IntervalsMatrix,'String',vars)
set(handles.Xmatrix,'String',vars)
% --- Executes on selection change in ListMatrix.
function ListMatrix_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function ListMatrix_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function NumberOfLvlBox_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function NumberOfLvlBox_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in preProcessListbox.
function preProcessListbox_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function preProcessListbox_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Intervals_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function Intervals_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in ListAxis.
function ListAxis_Callback(hObject, eventdata, handles)
function [myAxis] = getAxisNames(handles)
listEntriesAxis = get(handles.ListAxis,'String')
indexSelecteAxis = get(handles.ListAxis,'Value')
myAxis = listEntriesAxis{indexSelecteAxis(1)}
% --- Executes during object creation, after setting all properties.
function ListAxis_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in makeClasses.
function makeClasses_Callback(hObject, eventdata, handles)
assignin('base', 'classes',[1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;2;])
% --- Executes on button press in LoadDemoSet.
function LoadDemoSet_Callback(hObject, eventdata, handles)
nirbeer=load('Nirbeer');
assignin('base', 'nirbeer',nirbeer);
xaxis=nirbeer.xaxis;
Xcal=nirbeer.Xcal;
ycal=nirbeer.ycal;
Xtest=nirbeer.Xtest;
ytest=nirbeer.ytest;
assignin('base', 'xaxis',xaxis);
assignin('base', 'Xcal',Xcal);
assignin('base', 'ycal',ycal);
assignin('base', 'Xtest',Xtest);
assignin('base', 'Xcal',Xcal);
% --- Executes on button press in UpdateWorkspace.
function UpdateWorkspace_Callback(hObject, eventdata, handles)
vars = evalin('base','who');
set(handles.Xmatrix,'String',vars)
set(handles.ListAxis,'String',vars)
set(handles.IntervalsMatrix,'String',vars)
set(handles.Ymatrix,'String',vars)
% --- Executes on button press in loadFilesButton.
function loadFilesButton_Callback(hObject, eventdata, handles)
filename = uigetfile ('*.*')
myfile= load (filename)
assignin('base', 'myfile', myfile)
% --- Executes on button press in doIpca.
function doIpca_Callback(hObject, eventdata, handles)
listEntriesXmatrix = get(handles.Xmatrix,'String');
indexSelectedXmatrix = get(handles.Xmatrix,'Value');
mymatrix = evalin('base',listEntriesXmatrix{indexSelectedXmatrix(1)});
listEntriesYmatrix = get(handles.Ymatrix,'String');
indexSelectedYmatrix = get(handles.Ymatrix,'Value');
myYmatrix = evalin('base',listEntriesYmatrix{indexSelectedYmatrix(1)});
listEntriesAxis = get(handles.ListAxis,'String');
indexSelecteAxis = get(handles.ListAxis,'Value');
myAxis = evalin('base',listEntriesAxis{indexSelecteAxis(1)});
listIntervalsMatrix = get(handles.IntervalsMatrix,'String');
indexIntervalsMatrix = get(handles.IntervalsMatrix,'Value');
Intervals = evalin('base',listIntervalsMatrix{indexIntervalsMatrix(1)});
preprocindex = int2str(get(handles.PreprocessListbox,'Value'));
switch preprocindex
case {'1'}
preproc='none';
case '2'
preproc='mean';
case '3'
preproc='auto';
case '4'
preproc='mscmean';
case '5'
preproc='mscauto';
end
%assignin('base', 'preproc', preproc);
validation = int2str(get(handles.validation,'Value'));
switch validation
case {'1'}
valMethod='test';
case '2'
valMethod='full';
case '3'
valMethod='syst111';
case '4'
valMethod='syst123';
case '5'
valMethod='random';
end
Modelname = get(handles.IplsModel,'String');
numberOfComponents = str2double(get(handles.NumberOfLvlBox,'String'));
numberOfIntervals = str2double(get(handles.IntervalsBox,'String'));
numberOfSegments = str2double(get(handles.Segments,'String'));
if (get(handles.checkIntervals,'Value') == get(handles.checkIntervals,'Max')) & (get(handles.checkAxis,'Value') == get(handles.checkAxis,'Max'))
Modelipls=ipls(mymatrix,myYmatrix,numberOfComponents,preproc,Intervals,myAxis,valMethod,numberOfSegments);
elseif (get(handles.checkIntervals,'Value') == get(handles.checkIntervals,'Min')) & (get(handles.checkAxis,'Value') == get(handles.checkAxis,'Min'))
Modelipls=ipls(mymatrix,myYmatrix,numberOfComponents,preproc,numberOfIntervals,[],valMethod,numberOfSegments);
elseif (get(handles.checkIntervals,'Value') == get(handles.checkIntervals,'Max')) & (get(handles.checkAxis,'Value') == get(handles.checkAxis,'Min'))
Modelipls=ipls(mymatrix,myYmatrix,numberOfComponents,preproc,Intervals,[],valMethod,numberOfSegments);
else
Modelipls=ipls(mymatrix,myYmatrix,numberOfComponents,preproc,numberOfIntervals,myAxis,valMethod,numberOfSegments);
end
assignin('base', Modelname, Modelipls)
% --- Executes on selection change in PreprocessListbox.
function PreprocessListbox_Callback(hObject, eventdata, handles)
%contents = get(handles.PreprocessListbox,'String')
% --- Executes during object creation, after setting all properties.
function PreprocessListbox_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in plotGUI.
function plotGUI_Callback(hObject, eventdata, handles)
IplsPlotGUI
function IntervalsBox_Callback(hObject, eventdata, handles)
% --- Executes on button press in makeManualIntervals.
function makeManualIntervals_Callback(hObject, eventdata, handles)
% VIS NIR NOISE
% st1 end1 st2 end2 st3 end3
int_vec=[1 200 201 500 501 926];
assignin('base', 'int_vec',int_vec);
% --- Executes on selection change in intervalsMatrix.
function intervalsMatrix_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function intervalsMatrix_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in checkIntervals.
function checkIntervals_Callback(hObject, eventdata, handles)
if (get(handles.checkIntervals,'Value') == get(handles.checkIntervals,'Max'))
set(handles.IntervalsBox,'Enable', 'off')
set(handles.IntervalsMatrix,'Enable', 'on')
else
set(handles.IntervalsBox,'Enable', 'on')
set(handles.IntervalsMatrix,'Enable', 'off')
end
% --- Executes on selection change in IntervalsMatrix.
function IntervalsMatrix_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function IntervalsMatrix_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function segments_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function segments_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in Ymatrix.
function Ymatrix_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function Ymatrix_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Segments_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function Segments_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in validation.
function validation_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function validation_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in checkAxis.
function checkAxis_Callback(hObject, eventdata, handles)
if (get(handles.checkAxis,'Value') == get(handles.checkAxis,'Max'))
set(handles.ListAxis,'Enable', 'on')
else
set(handles.ListAxis,'Enable', 'off')
end
% --- Executes when figure1 is resized.
function figure1_ResizeFcn(hObject, eventdata, handles)
function IplsModel_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function IplsModel_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes during object creation, after setting all properties.
function Namelabel_CreateFcn(hObject, eventdata, handles)
% --- Executes during object deletion, before destroying properties.
function IplsModel_DeleteFcn(hObject, eventdata, handles)
% --- Executes during object deletion, before destroying properties.
function Namelabel_DeleteFcn(hObject, eventdata, handles)
function IplsModel_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function IplsModel_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes during object deletion, before destroying properties.
function IplsModel_DeleteFcn(hObject, eventdata, handles)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -