Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
function mycallback

Subject: function mycallback

From: pink

Date: 4 Jun, 2011 08:23:04

Message: 1 of 5

how to create function mycallback(obj, eventdata) for timer?

Subject: function mycallback

From: Nasser M. Abbasi

Date: 4 Jun, 2011 08:31:16

Message: 2 of 5

On 6/4/2011 1:23 AM, pink wrote:
> how to create function mycallback(obj, eventdata) for timer?

doc timer

Subject: function mycallback

From: pink

Date: 4 Jun, 2011 08:56:02

Message: 3 of 5

"Nasser M. Abbasi" <nma@12000.org> wrote in message <iscqgk$u89$1@speranza.aioe.org>...
> On 6/4/2011 1:23 AM, pink wrote:
> > how to create function mycallback(obj, eventdata) for timer?
>
> doc timer

I've tried it many times but the result of errors, can you help me give advice
my code
function togglebutton1_Callback(hObject, eventdata, handles)
t=timer('TimerFcn',(@axes1.handles),'BusyMode','queue','executionmode','singleShot','period',0.5);

button_state = get(hObject,'Value')
handles.togglebutton1=1
if button_state == get(hObject,'Max')
        while handles.togglebutton1==1
            start(t)
            camorbit(1,0,'data',[0 0 1])
            drawnow
        end
elseif button_state == get(hObject,'Min')
    stop (t)
end

The above code can run but can not be stopped if the return is pressed the button and remove the error message such as this

??? Error while evaluating TimerFcn for timer 'timer-5'
Undefined function or method 'desain.handles' for input arguments of type 'timer'.

??? Error while evaluating TimerFcn for timer 'timer-5'
Undefined function or method 'desain.handles' for input arguments of type 'timer'.

please help
thanks

Subject: function mycallback

From: Steven_Lord

Date: 6 Jun, 2011 01:01:52

Message: 4 of 5



"pink " <wahyoe_slipnot@yahoo.co.id> wrote in message
news:iscq18$fbq$1@newscl01ah.mathworks.com...
> how to create function mycallback(obj, eventdata) for timer?

Open a new function file in the Editor and save it using the name you want
for your callback function.

Put this as the first line in the file:

    function mycallback(obj, eventdata)

replacing "mycallback" with the name you chose for the file (without the .m
extension.)

Fill in the rest of the body of the function with the instructions you want
to use.

When you create the timer, use @ followed by the name of the file (again
without the .m extension) as the value for the TimerFcn property.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: function mycallback

From: pink

Date: 6 Jun, 2011 07:00:20

Message: 5 of 5

"Steven_Lord" <slord@mathworks.com> wrote in message <ish90s$ea9$1@newscl01ah.mathworks.com>...
>
>
> "pink " <wahyoe_slipnot@yahoo.co.id> wrote in message
> news:iscq18$fbq$1@newscl01ah.mathworks.com...
> > how to create function mycallback(obj, eventdata) for timer?
>
> Open a new function file in the Editor and save it using the name you want
> for your callback function.
>
> Put this as the first line in the file:
>
> function mycallback(obj, eventdata)
>
> replacing "mycallback" with the name you chose for the file (without the .m
> extension.)
>
> Fill in the rest of the body of the function with the instructions you want
> to use.

steve, thanks very much
> When you create the timer, use @ followed by the name of the file (again
> without the .m extension) as the value for the TimerFcn property.
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us