Below is some code I am trying to include in part of my program. It
is essentially a timer function that counts the number of seconds,
minutes and hours since the timer was started (on a button press)
When I am using the 'disp' feature the correct outputs are displayed.
However, when I try to include this with the gui I have created I run
into problems. I use three edit boxes to display the hours, minutes
and seconds since the timer was started. The problem is when I try to
replace the 'disp' function with the line
set(handles.ClockSeconds,'string',num2str(x));
an error is raised with the message that says
Undefined variable 'handles' or class 'handles.ClockSeconds'.
The edit box being addressed has the ClockSeconds tag and the rest of
the code works correctly when using the disp function so I am
confused to what the problem is.
I have the same problem if either of the ClockMinutes or ClockHours
handles are used also, they also have the correct tags.
Any ideas on what could be wrong/
Thanks
Iain
function t = clockmain
global x y z
% Main function for building a timed application
t = timer;
set(t,'ExecutionMode','fixedRate')
set(t,'Period',1)
set(t,'TimerFcn',@myclock)
start(t)
x=0;
y=0;
z=0;
function myclock(t,event)
global x y z
% MYCLOCK Timer Callback function for clockmain
x=x+1;
disp(z)
disp(y)
disp(x)
if x==59
y=y+1;
x=0;
end
if y==59
z=z+1;
y=0;
end
|
|
0
|
|
|
|
Reply
|
imurdoch (17)
|
1/22/2004 9:00:03 AM |
|
Iain wrote:
> Below is some code I am trying to include in part of my program. It
> is essentially a timer function that counts the number of seconds,
> minutes and hours since the timer was started (on a button press)
> When I am using the 'disp' feature the correct outputs are displayed.
> However, when I try to include this with the gui I have created I run
> into problems. I use three edit boxes to display the hours, minutes
> and seconds since the timer was started. The problem is when I try to
> replace the 'disp' function with the line
> set(handles.ClockSeconds,'string',num2str(x));
> an error is raised with the message that says
> Undefined variable 'handles' or class 'handles.ClockSeconds'.
>
> The edit box being addressed has the ClockSeconds tag and the rest of
> the code works correctly when using the disp function so I am
> confused to what the problem is.
> I have the same problem if either of the ClockMinutes or ClockHours
> handles are used also, they also have the correct tags.
*snip*
> function myclock(t,event)
> global x y z
> % MYCLOCK Timer Callback function for clockmain
> x=x+1;
> disp(z)
> disp(y)
> disp(x)
> if x==59
> y=y+1;
> x=0;
> end
> if y==59
> z=z+1;
> y=0;
> end
Where in this code are you retrieving the handles structure from the GUI?
Call GUIHANDLES before attempting to call your SET call above. This way,
the handles structure is defined when you try to index into it to get the
handles to your text boxes.
--
Steve Lord
slord@mathworks.com
|
|
0
|
|
|
|
Reply
|
slord (13276)
|
1/22/2004 1:06:17 PM
|
|
Thank you for the info - I now have it working as required, your
assistance is appreciated.
Iain
|
|
0
|
|
|
|
Reply
|
imurdoch (17)
|
1/23/2004 7:07:02 AM
|
|
|
2 Replies
45 Views
(page loaded in 0.02 seconds)
Similiar Articles: stopping the timer object - comp.soft-sys.matlabError while evaluating TimerFcn for timer 'timer-72' > > Invalid handle object. Please examine the TimerFcn, which causes the error! If the error appears after ... timer function in GUIDE - comp.soft-sys.matlabI'm really new and I program a lot in a try-error way so I have ... start(refreshTimer); > > You should store the timer object somewhere (say inside the handles ... GUI handles - not object handles - comp.soft-sys.matlab... timer, handles - comp.soft-sys.matlab stopping the timer object - comp.soft-sys.matlab GUI, timer, handles ... error: "Reference to a cleared variable handles" - comp.soft ... display a clock in a gui matlab in textbox? - comp.soft-sys.matlab ...Let me know if there is an error before I publish ... updater}); > start(tmr); % Start the timer object. ... GUI, timer, handles - comp.soft-sys.matlab display a clock ... Error while evaluating TimerFCN for timer 'timer-1' - comp.soft ...... for timer 'timer-1' Error ... stopping the timer object - comp.soft-sys.matlab Error ... variable handles" - comp.soft-sys ... Error while evaluating TimerFCN for timer ... How to make a stopwatch run in matlab gui? - comp.soft-sys.matlab ...Do you get an error? Did it not error, but not do ... in GUI ... timer function in ... stopping the timer object ... ... GUI, timer, handles - comp.soft-sys.matlab How to make a ... live video handles is run in other axes when doing process of ...Error that written in command window: ??? Error ... % Clean up - delete any image acquisition objects 'end']); handles ... GETSNAPSHOT, > waitfor, subplot, and the timer. comp.soft-sys.matlab - page 376Timer Object & handles error 2 5 (1/22/2004 9:00:03 AM) Below is some code I am trying to include in part of my program. It is essentially a timer function that counts the ... comp.soft-sys.matlabThis is page 0 of the comp.soft-sys.matlab group which contains 190309 articles. Clearing handles - comp.soft-sys.matlab... with new handles, but if I don't overwrite them all, I get errors regarding removed objects. ... imEllipse objects, the handles ... and timer function in GUI ..... handle to ... CreateWaitableTimer function - Microsoft Corporation: Software ...If the named timer object exists before the function call, the function returns a handle to the existing object and GetLastError returns ERROR_ALREADY_EXISTS. Construct timer object - MATLAB - MathWorks - MATLAB and Simulink ...This MATLAB function constructs a timer object ... that the timer executes when an error ... This example constructs a timer object with a timer callback function handle, ... 7/20/2012 4:12:32 PM
|