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

📄 zhuo_se_1_011.m

📁 初学者设计的matlab顶点问题着色问题gui解决
💻 M
字号:
function varargout = zhuo_se_1_02(varargin)
% ZHUO_SE_1_02 M-file for zhuo_se_1_02.fig
%      ZHUO_SE_1_02, by itself, creates a new ZHUO_SE_1_02 or raises the existing
%      singleton*.
%
%      H = ZHUO_SE_1_02 returns the handle to a new ZHUO_SE_1_02 or the handle to
%      the existing singleton*.
%
%      ZHUO_SE_1_02('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in ZHUO_SE_1_02.M with the given input arguments.
%
%      ZHUO_SE_1_02('Property','Value',...) creates a new ZHUO_SE_1_02 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before zhuo_se_1_02_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to zhuo_se_1_02_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 zhuo_se_1_02

% Last Modified by GUIDE v2.5 28-Mar-2009 23:39:30

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @zhuo_se_1_02_OpeningFcn, ...
                   'gui_OutputFcn',  @zhuo_se_1_02_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 zhuo_se_1_02 is made visible.
function zhuo_se_1_02_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 zhuo_se_1_02 (see VARARGIN)
axis('off');
hold on;
global A;
global P;
global joint1;
global joint2;
%point_Callback(handles.point, eventdata, handles);
% Choose default command line output for zhuo_se_1_02
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = zhuo_se_1_02_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;



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 point_Callback(hObject, eventdata, handles)
% hObject    handle to point (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 point as text
%        str2double(get(hObject,'String')) returns contents of point as a double
global A;
global P;
n=str2double(get(hObject,'String'));
sp_n_s = 0.05;%space between point and text
t=linspace(2*pi,0,n+1);
P=[sin(t);cos(t)];
scatter(P(1,:),P(2,:),50,'r','filled');
for i=1:n
    stri=int2str(i);
    text(P(1,i)+sp_n_s,P(2,i),stri);
end
hold on;
axis('off');
A = zeros(n);

Join1_Callback(handles.Join1, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function point_CreateFcn(hObject, eventdata, handles)
% hObject    handle to point (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 colour_Callback(hObject, eventdata, handles)
% hObject    handle to colour (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 colour as text
%        str2double(get(hObject,'String')) returns contents of colour as a double


% --- Executes during object creation, after setting all properties.
function colour_CreateFcn(hObject, eventdata, handles)
% hObject    handle to colour (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 Join1_Callback(hObject, eventdata, handles)
% hObject    handle to Join1 (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 Join1 as text
%        str2double(get(hObject,'String')) returns contents of Join1 as a double

global joint1;
joint1=str2num(get(hObject,'String'));
set(handles.join2,'String','');
% --- Executes during object creation, after setting all properties.
function Join1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Join1 (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 join2_Callback(hObject, eventdata, handles)
% hObject    handle to join2 (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 join2 as text
%        str2double(get(hObject,'String')) returns contents of join2 as a double
global joint1;
global joint2;
global A;
global P;
joint2 = str2num(get(hObject,'String'));
A(joint1,joint2)=1;
A(joint2,joint1) = 1;
X=[P(1,joint1),P(1,joint2)];
Y=[P(2,joint1),P(2,joint2)];
plot(X,Y);
set(handles.Join1,'String','');
hold on;
% --- Executes during object creation, after setting all properties.
function join2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to join2 (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 button press in ok.
function ok_Callback(hObject, eventdata, handles)
% hObject    handle to ok (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 Reset.
function Reset_Callback(hObject, eventdata, handles)
% hObject    handle to Reset (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.point,'String','');
set(handles.Join1,'String','');
set(handles.join2,'String','');
set(handles.colour,'String','');

% --- Executes on button press in caculate.
function caculate_Callback(hObject, eventdata, handles)
% hObject    handle to caculate (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 close.
function close_Callback(hObject, eventdata, handles)
% hObject    handle to close (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
clc;
clear all;
close(gcf);


⌨️ 快捷键说明

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