偶有灵感,做了一个自动画正玄曲线曲线的界面,分享一下
界面文件如下:
本帖隐藏的内容
在figure上移动移动自己的鼠标,按一按自己的鼠标。
主程序:
本帖隐藏的内容
- function varargout = Active_Gui_Plot(varargin)
- % ACTIVE_GUI_PLOT M-file for Active_Gui_Plot.fig
- % ACTIVE_GUI_PLOT, by itself, creates a new ACTIVE_GUI_PLOT or raises the existing
- % singleton*.
- %
- % H = ACTIVE_GUI_PLOT returns the handle to a new ACTIVE_GUI_PLOT or the handle to
- % the existing singleton*.
- %
- % ACTIVE_GUI_PLOT('CALLBACK',hObject,eventData,handles,...) calls the local
- % function named CALLBACK in ACTIVE_GUI_PLOT.M with the given input arguments.
- %
- % ACTIVE_GUI_PLOT('Property','Value',...) creates a new ACTIVE_GUI_PLOT or raises the
- % existing singleton*. Starting from the left, property value pairs are
- % applied to the GUI before Active_Gui_Plot_OpeningFcn gets called. An
- % unrecognized property name or invalid value makes property application
- % stop. All inputs are passed to Active_Gui_Plot_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 Active_Gui_Plot
- % Last Modified by GUIDE v2.5 03-Jan-2015 22:15:34
- % Begin initialization code - DO NOT EDIT
- gui_Singleton = 1;
- gui_State = struct('gui_Name', mfilename, ...
- 'gui_Singleton', gui_Singleton, ...
- 'gui_OpeningFcn', @Active_Gui_Plot_OpeningFcn, ...
- 'gui_OutputFcn', @Active_Gui_Plot_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 Active_Gui_Plot is made visible.
- function Active_Gui_Plot_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 Active_Gui_Plot (see VARARGIN)
- % Choose default command line output for Active_Gui_Plot
- handles.output = hObject;
- % Update handles structure
- guidata(hObject, handles);
- % UIWAIT makes Active_Gui_Plot wait for user response (see UIRESUME)
- % uiwait(handles.figure1);
- % --- Outputs from this function are returned to the command line.
- function varargout = Active_Gui_Plot_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;
- % --- Executes when user attempts to close figure1.
- function figure1_CloseRequestFcn(hObject, eventdata, handles)
- % hObject handle to figure1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % Hint: delete(hObject) closes the figure
- delete(hObject);
- clear all
- % --- Executes on mouse press over figure background, over a disabled or
- % --- inactive control, or over an axes background.
- function figure1_WindowButtonDownFcn(hObject, eventdata, handles)
- % hObject handle to figure1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- persistent g
- if isempty(g)
- g=0;
- end
- cla
- set(gca,'visible','off')
- g=g+1;
- set(hObject,'userdata',g)
- % --- Executes on mouse motion over figure - except title and menu.
- function figure1_WindowButtonMotionFcn(hObject, eventdata, handles)
- % hObject handle to figure1 (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- persistent c
- if isempty(c)
- c=0;
- end
- c=c+1;
- g=get(hObject,'userdata');
- t=0:0.1:c*pi/200;
- if g==0
- plot(sin(t),'ks-','markerface','r','markersize',8)
- elseif g==1
- plot(sin(t),'ko-','markerface','m','markersize',8)
- elseif g==2
- plot(sin(t),'kp-','markerface','g','markersize',8)
- else
- plot(sin(t),'kv-','markerface','c','markersize',8)
- end
- drawnow;
在理解与学习MATLAB中,需要大家是个多面手 —————— by faruto