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

📄 zhuo_se_1_02.m

📁 初学者设计的matlab顶点问题着色问题gui解决
💻 M
📖 第 1 页 / 共 2 页
字号:
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 01-Apr-2009 21:42:46

% 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;%the "juzhen"you want
global P;%the "zuobiao" of point
global NPOINT;%the total number of points
global JOINT1;%the first "dingdian"
global JOINT2;%the second "dingdian" 
global NCOLOUR;%the number of colour
global RESULT;
global DUOXIANGSHI;
global FENJIE;
%point_Callback(handles.point, eventdata, handles);
% Choose default command line output for zhuo_se_1_02 
NPOINT = 0;
JOINT1 = 0;
JOINT2 = 0;
NCOLOUR = 0;
RESULT = -1;
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;
global NPOINT;

if NPOINT == 0
    NPOINT=str2double(get(hObject,'String'));
    is_zheng = mod(NPOINT,1);%judge whether zhengshu
    if (NPOINT < 1)|(NPOINT == NaN)|(is_zheng~=0)
        msgbox('You must input a positive integer!','Wrong input','error');
        set(handles.point,'String','');
        NPOINT = 0;
    elseif NPOINT == 1
        X_1=10;
        Y_1=10;
        scatter(X_1,Y_1,50,'r','filled');
        hold on;
        axis('off');
        A = eye(NPOINT);
        set(handles.Join1,'String','');
        set(handles.join2,'String','');
    elseif NPOINT == 2
        P=[10,10;20,10];
        scatter(P(1,:),P(2,:),50,'r','filled');
        sp_n_s=0.05; %the space between point and text
        for i=1:NPOINT
            stri=int2str(i);
                text(P(1,i)+sp_n_s,P(2,i),stri);
        end
        hold on;
        axis('off');
        A = eye(NPOINT);
        set(handles.Join1,'String','');
        set(handles.join2,'String','');
    
    else
        t=linspace(2*pi,0,NPOINT+1);
        P=[sin(t);cos(t)];
        scatter(P(1,:),P(2,:),50,'r','filled');
        sp_n_s=0.05; %the space between point and text
        for i=1:NPOINT
            stri=int2str(i);
                text(P(1,i)+sp_n_s,P(2,i),stri);
        end
        hold on;
        axis('off');
        A = eye(NPOINT);
        set(handles.Join1,'String','');
        set(handles.join2,'String','');
    end
else
    
    Reset_Callback(handles.Reset, eventdata, handles);
    
end
% --- 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
global NCOLOUR;
NCOLOUR=str2double(get(hObject,'String'));
is_zheng = mod(NCOLOUR,1);%judge whether zhengshu
if (NCOLOUR < 1)|(NCOLOUR == NaN)|(is_zheng~=0)
    msgbox('You must input a positive integer!','Wrong input','error');
    set(handles.colour,'String','');
    NCOLOUR = 0;
end
%keyboard


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

⌨️ 快捷键说明

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