Path: news.mathworks.com!not-for-mail
From: "helper " <spamless@nospam.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: timer and callback routine
Date: Fri, 16 May 2008 03:04:01 +0000 (UTC)
Organization: Timothy S. Farajian, Inc.
Lines: 30
Message-ID: <g0itj1$2m0$1@fred.mathworks.com>
References: <g0ih9a$brn$1@fred.mathworks.com>
Reply-To: "helper " <spamless@nospam.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1210907041 2752 172.30.248.38 (16 May 2008 03:04:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 16 May 2008 03:04:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1272923
Xref: news.mathworks.com comp.soft-sys.matlab:468760


"Paul " <par@ceri.memphis.edu> wrote in message 
<g0ih9a$brn$1@fred.mathworks.com>...
> I've trying to code a timer that will start a data
> acquisition  program at a certain time.  
> 
> The problem I have is that the callback function in the
> timer routine is just that ... a call to a 'function'. 
> Therefore the more general question would be:  how to
> execute a callback 'program' and not a 'function'.  Or
> should I just somehow rewrite the data acquisition program
> to look like a function?
> 
> 


What you are calling a "program" is typically referred to 
as a "script"...and yes, rewrite it to be a function.  And 
it isn't difficult.  At the very first line of your 
script/program, add the line:

function MyDAQFunction
<add script code here>

Then set the "TimerFcn" property of the timer to "@(x,y)
MyDAQFunction" (without the quotes).  Oh, also be sure to 
save the function as the name "MyDAQFunction.m".  It is the 
name it is saved as that matters, not the name after the 
FUNCTION keyword.

Function created!  Good luck