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

📄 plot2dgenericgui.m

📁 这是国外一个PLS工具箱
💻 M
📖 第 1 页 / 共 2 页
字号:
end


% --- Executes on button press in EqualBox.
function EqualBox_Callback(hObject, eventdata, handles)
% hObject    handle to EqualBox (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of EqualBox


% --- Executes on selection change in MyMatrix.
function MyMatrix_Callback(hObject, eventdata, handles)
% hObject    handle to MyMatrix (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 MyMatrix contents as cell array
%        contents{get(hObject,'Value')} returns selected item from MyMatrix


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


% --- Executes on selection change in MyClasses.
function MyClasses_Callback(hObject, eventdata, handles)
% hObject    handle to MyClasses (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 MyClasses contents as cell array
%        contents{get(hObject,'Value')} returns selected item from MyClasses


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


% --- Executes on selection change in listbox3.
function listbox3_Callback(hObject, eventdata, handles)
% hObject    handle to listbox3 (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 listbox3 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox3


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


% --- Executes on button press in ClassesCheck.
function ClassesCheck_Callback(hObject, eventdata, handles)
% hObject    handle to ClassesCheck (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of ClassesCheck
if (get(handles.ClassesCheck,'Value') == get(handles.ClassesCheck,'Max'))
    % then checkbox is checked-take approriate action
     set(handles.MyClasses,'Enable', 'on')
   
else
     set(handles.MyClasses,'Enable', 'off')
        
end

% --- Executes on button press in NamesCheck.
function NamesCheck_Callback(hObject, eventdata, handles)

if (get(handles.NamesCheck,'Value') == get(handles.NamesCheck,'Max'))
    % then checkbox is checked-take approriate action
     set(handles.MyNames,'Enable', 'on')
   
else
     set(handles.MyNames,'Enable', 'off')
        
end
% hObject    handle to NamesCheck (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of NamesCheck





function YAxis_Callback(hObject, eventdata, handles)
% hObject    handle to YAxis (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 YAxis as text
%        str2double(get(hObject,'String')) returns contents of YAxis as a double


% --- Executes during object creation, after setting all properties.
function YAxis_CreateFcn(hObject, eventdata, handles)
% hObject    handle to YAxis (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,'BackgroundColor','white');
end



function XLabel_Callback(hObject, eventdata, handles)
% hObject    handle to XLabel (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 XLabel as text
%        str2double(get(hObject,'String')) returns contents of XLabel as a double


% --- Executes during object creation, after setting all properties.
function XLabel_CreateFcn(hObject, eventdata, handles)
% hObject    handle to XLabel (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,'BackgroundColor','white');
end



function XExpansion_Callback(hObject, eventdata, handles)
% hObject    handle to XExpansion (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 XExpansion as text
%        str2double(get(hObject,'String')) returns contents of XExpansion as a double


% --- Executes during object creation, after setting all properties.
function XExpansion_CreateFcn(hObject, eventdata, handles)
% hObject    handle to XExpansion (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,'BackgroundColor','white');
end





function YExpansion_Callback(hObject, eventdata, handles)
% hObject    handle to YExpansion (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 YExpansion as text
%        str2double(get(hObject,'String')) returns contents of YExpansion as a double


% --- Executes during object creation, after setting all properties.
function YExpansion_CreateFcn(hObject, eventdata, handles)
% hObject    handle to YExpansion (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,'BackgroundColor','white');
end




% --- Executes on button press in Scatter.
function Scatter_Callback(hObject, eventdata, handles)
% hObject    handle to Scatter (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


v1=str2double(get(handles.XAxis,'String'));
v2=str2double(get(handles.YAxis,'String'));
hl=get(handles.XLabel,'String');
vl=get(handles.YLabel,'String');
tt=get(handles.Title,'String');
esp1=str2double(get(handles.XExpansion,'String'));
esp2=str2double(get(handles.YExpansion,'String'));

listMyMatrix = get(handles.MyMatrix,'String');
indexMyMatrix = get(handles.MyMatrix,'Value');
MyMatrix = evalin('base',listMyMatrix{indexMyMatrix(1)});

listMyNames = get(handles.MyNames,'String');
indexMyNames = get(handles.MyNames,'Value');
MyNames = evalin('base',listMyNames{indexMyNames(1)});

figure
h=scatter(MyMatrix(:,v1),MyMatrix(:,v2));

set(gca,'XLim',[(min(MyMatrix(:,v1))-(0.01*esp1*(max(MyMatrix(:,v1))-min(MyMatrix(:,v1))))) (max(MyMatrix(:,v1))+(0.01*esp1*(max(MyMatrix(:,v1))-min(MyMatrix(:,v1)))))]);
set(gca,'YLim',[(min(MyMatrix(:,v2))-(0.01*esp2*(max(MyMatrix(:,v2))-min(MyMatrix(:,v2))))) (max(MyMatrix(:,v2))+(0.01*esp2*(max(MyMatrix(:,v2))-min(MyMatrix(:,v2)))))]);
set(gca,'xlabel',text(0,0,hl));
set(gca,'ylabel',text(0,0,vl));
title (tt);

if get(handles.EqualBox,'Value') == get(handles.EqualBox,'Max')
     axis('equal');
end

gname(MyNames)

% --- Executes on button press in GScatter.
function GScatter_Callback(hObject, eventdata, handles)

v1=str2double(get(handles.XAxis,'String'));
v2=str2double(get(handles.YAxis,'String'));
hl=get(handles.XLabel,'String');
vl=get(handles.YLabel,'String');
tt=get(handles.Title,'String');
esp1=str2double(get(handles.XExpansion,'String'));
esp2=str2double(get(handles.YExpansion,'String'));

listMyMatrix = get(handles.MyMatrix,'String');
indexMyMatrix = get(handles.MyMatrix,'Value');
MyMatrix = evalin('base',listMyMatrix{indexMyMatrix(1)});

listMyNames = get(handles.MyNames,'String');
indexMyNames = get(handles.MyNames,'Value');
MyNames = evalin('base',listMyNames{indexMyNames(1)});

listMyClasses = get(handles.MyClasses,'String');
indexMyClasses = get(handles.MyClasses,'Value');
MyClasses = evalin('base',listMyClasses{indexMyClasses(1)});


figure
h=gscatter(MyMatrix(:,v1),MyMatrix(:,v2),MyClasses);

set(gca,'XLim',[(min(MyMatrix(:,v1))-(0.01*esp1*(max(MyMatrix(:,v1))-min(MyMatrix(:,v1))))) (max(MyMatrix(:,v1))+(0.01*esp1*(max(MyMatrix(:,v1))-min(MyMatrix(:,v1)))))]);
set(gca,'YLim',[(min(MyMatrix(:,v2))-(0.01*esp2*(max(MyMatrix(:,v2))-min(MyMatrix(:,v2))))) (max(MyMatrix(:,v2))+(0.01*esp2*(max(MyMatrix(:,v2))-min(MyMatrix(:,v2)))))]);
set(gca,'xlabel',text(0,0,hl));
set(gca,'ylabel',text(0,0,vl));
title (tt);

if get(handles.EqualBox,'Value') == get(handles.EqualBox,'Max')
     axis('equal');
end

gname(MyNames)
% hObject    handle to GScatter (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


⌨️ 快捷键说明

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