gui callback stop problem...

1 visualización (últimos 30 días)
vishwash saxena
vishwash saxena el 24 de Feb. de 2011
hiii frns....... i have been working on my project... in this i have a long continuous programme of plotting a data.. but problem is while the for loop is executing i cant stop it with my reset button.. pls help me out.. here is the programme code..
function varargout = soln(varargin)
% SOLN M-file for soln.fig
% SOLN, by itself, creates a new SOLN or raises the existing
% singleton*.
%
% H = SOLN returns the handle to a new SOLN or the handle to
% the existing singleton*.
%
% SOLN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SOLN.M with the given input arguments.
%
% SOLN('Property','Value',...) creates a new SOLN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before soln_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to soln_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 soln
% Last Modified by GUIDE v2.5 25-Feb-2011 00:49:15
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @soln_OpeningFcn, ... 'gui_OutputFcn', @soln_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 soln is made visible. function soln_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 soln (see VARARGIN)
% Choose default command line output for soln handles.output = hObject;
% Update handles structure guidata(hObject, handles);
% UIWAIT makes soln wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. function varargout = soln_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 on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) x1=0; y1=0; axes(handles.axes1) title('Axes 1'); xlabel('X data'); ylabel('Y data'); x11=0; y11=0; axes(handles.axes2) title('Axes 2'); xlabel('X data'); ylabel('Y data'); for i=0:1:200 axes(handles.axes1) x2=i y2=exp(x2); x=[x1 x2]; y=[y1 y2]; line(x,y); drawnow x1=x2; y1=y2; pause(.001); axes(handles.axes2) x22=i y22=exp(x22)+randn; x3=[x11 x22]; y3=[y11 y22]; line(x3,y3); drawnow x11=x22; y11=y22; pause(.001); end guidata(hObject, handles);
% hObject handle to pushbutton1 (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 pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles)
for j=0:1:400
end guidata(hObject, handles);
% 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 pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) cla(handles.axes1); pause(0.5); guidata(hObject, handles); % hObject handle to pushbutton3 (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 pushbutton4. function pushbutton4_Callback(hObject, eventdata, handles) cla(handles.axes2); pause(0.5); guidata(hObject, handles); % hObject handle to pushbutton4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
  1 comentario
Jan
Jan el 25 de Feb. de 2011
As you can see also, it is nearly impossible to read your code. Please use a correct formatting, if you post here. It is a good idea also to omit all running code and concentrate on the part causing the problem only. I simply cannot find the mentioned FOR loop within 20 seconds and decide to care for another thread.

Iniciar sesión para comentar.

Respuestas (3)

Matt Fig
Matt Fig el 25 de Feb. de 2011
Are you talking about this FOR loop:
for j=0:1:400
end guidata(hObject, handles);
There is nothing in the body of that loop! How could you know whether you are able to stop that loop or not, when on even the slowest computer that loop has to run in just a tiny fraction of a second? Please format your question properly, then clarify your question and give more details.

Paulo Silva
Paulo Silva el 25 de Feb. de 2011
Here's a program that I did that uses buttons to control a loop, although right now I don't recommend the use of global variables (I learned to avoid them whenever possible) it does work, please see the code for http://www.mathworks.com/matlabcentral/fileexchange/29618-spspj

vishwash saxena
vishwash saxena el 25 de Feb. de 2011
sorry about the format...
i tried using gloabal variables and it worked
thanx a lot...

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by