How to save output arguments from functions called by timers
Show older comments
Hello guys, I have a question I'm sure you guys can solve in about 5 seconds. Suppose I have the following function:
function z = executethis(t,c)
z =randn();
end
Suppose also that I have the following timer object defined: t=timer('TimerFcn',@(t,c,x)executethis,'Period',2,'ExecutionMode','fixedRate')
which I then initiate with start(t).
I want to save the output argument from the function every 2 seconds into a vector in my workspace. However, I'm not sure how to do this. Any help will be appreciated.
Thank you.
Accepted Answer
More Answers (1)
Damien T
on 5 Feb 2022
0 votes
Timers have a "UserData" property for passing data to/from callback functions.
Categories
Find more on Code Execution 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!