- Are you using the Parallel Toolbox? The tag says so, but you don't mention it in your question.
- "continuously and in parallel," - Matlab is basically single threaded.
- Run out = timerfindall after the two callbacks have fired. What does it say?
- Change the name timerFnc to start_my_timers so that you don't confuse people!
How can I run two timer objects for infinite function callback in parallel in Matlab (R2012a)
2 views (last 30 days)
Show older comments
Since read up the answers from Answers:98217, which is very similar of what I am going to achieve. I am trying to compute two tasks continuously at same time in MATLAB, one is taking image frame from an IP cam, and do some object tracking to it, and another one is displaying various sensors data from other devices, I am able do these tasks individually in MATLAB, however not together. Currently, consulting the sample code offered in Answer 98217, as the code described, I am using two timer objects for each task: T_sen and T_cam, firing at different speed to callback the sensor display and camera functions in parallel computing, the timerFnc is called twice to assign to different tasks, and once the timer start, I expect it should callback the function continuously and in parallel, however the callback end up to only be executed once. May I have any suggestion on this? My timer function is written as below:
function timerFnc(period, ttype)
if ttype == 1
t=timer('ExecutionMode','fixedrate','Period',period,'TimerFcn',@sens_disp);
start(t);
else
t=timer('ExecutionMode','fixedrate','Period',period,'TimerFcn',@camera);
start(t);
end
end
3 Comments
per isakson
on 4 Mar 2014
Edited: per isakson
on 4 Mar 2014
- Assuming that you didn't use the Parallel Toolbox, I meant that you should run out = timerfindall interactively (in the command window) to see what happened to the timers. If they encounters errors timers may stop automatically.
- Maybe you want to make a few simpler experiments with one new feature at a time.
Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!