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:
timer function

Subject: timer function

From: Jose

Date: 10 Jul, 2010 18:41:05

Message: 1 of 3

Hello to everyone, there another way to pass all the variables sm.... through the function timerFun instead of define them as global?..thanks in advance.


function prueba

t1 = timer('TimerFcn',@timerFun,'executionmode','fixedrate');
start(t1);

global sm_ack
global sm_init
global sm_startmove
global sm_endmove
global sm_adc
global sm_elpsn
%






% receive the variable1
sm_ack=6
sm_init=5;
sm_startmove=1;
sm_endmove=2;
sm_adc=3;
sm_elpsn=4;





    


function timerFun(obj,~)
    
hstop=uicontrol (gcf,'String','Stop','Position',[10,10,60,20],'Callback','stoprun');
end

end

Subject: timer function

From: us

Date: 10 Jul, 2010 18:53:04

Message: 2 of 3

"Jose " <jose.l.vega@gmail.com> wrote in message <i1aes1$81b$1@fred.mathworks.com>...
> Hello to everyone, there another way to pass all the variables sm.... through the function timerFun instead of define them as global?..thanks in advance.
> function prueba
> t1 = timer('TimerFcn',@timerFun,'executionmode','fixedrate');
> start(t1);
> global sm_ack
> global sm_init
> global sm_startmove
> global sm_endmove
> global sm_adc
> global sm_elpsn
> %
> % receive the variable1
> sm_ack=6
> sm_init=5;
> sm_startmove=1;
> sm_endmove=2;
> sm_adc=3;
> sm_elpsn=4;
> function timerFun(obj,~)
>
> hstop=uicontrol (gcf,'String','Stop','Position',[10,10,60,20],'Callback','stoprun');
> end
>
> end

a hint:
- peruse the docs on how to create/use callback functions...

http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f9-39541.html#f9-42494

us

Subject: timer function

From: Jose

Date: 10 Jul, 2010 19:16:05

Message: 3 of 3

thanks, something like that
t1 = timer('TimerFcn',{@timerFun,sm_ack,sm_init,sm_start.move,sm_endmove,sm_adc,sm_elpsn},'executionmode','fixedrate');

It os too long I think, i need to write dowm some function.m for this kind of variables sm...something like sm.m

"us " <us@neurol.unizh.ch> wrote in message <i1afig$jic$1@fred.mathworks.com>...
> "Jose " <jose.l.vega@gmail.com> wrote in message <i1aes1$81b$1@fred.mathworks.com>...
> > Hello to everyone, there another way to pass all the variables sm.... through the function timerFun instead of define them as global?..thanks in advance.
> > function prueba
> > t1 = timer('TimerFcn',@timerFun,'executionmode','fixedrate');
> > start(t1);
> > global sm_ack
> > global sm_init
> > global sm_startmove
> > global sm_endmove
> > global sm_adc
> > global sm_elpsn
> > %
> > % receive the variable1
> > sm_ack=6
> > sm_init=5;
> > sm_startmove=1;
> > sm_endmove=2;
> > sm_adc=3;
> > sm_elpsn=4;
> > function timerFun(obj,~)
> >
> > hstop=uicontrol (gcf,'String','Stop','Position',[10,10,60,20],'Callback','stoprun');
> > end
> >
> > end
>
> a hint:
> - peruse the docs on how to create/use callback functions...
>
> http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f9-39541.html#f9-42494
>
> us

Tags for 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