How to use a timer to call a function, and assign it's output to a variable in the work space

3 views (last 30 days)
Hello,
I'm a new user, and I want to use a timer to call a function, and take that function's output argument to the main code.
I'v tried the following code, but it only prints the output value to the screen. Am I using the correct timer format? Please help.
assignin('base','A',1);
t = timer('TimerFcn', '[A] =time( A )', ...
'StartFcn', @(~,~)fprintf('AAA. %d \n',34)); % timer is defined
fTime = now + 5/(3600*24); % Timer is set for 5 sec (in serial time)Matlab
startat(t,fTime);
if A==2
C=A*4
end
function [ A ] = time( A )
A=A+1;
end

Answers (0)

Categories

Find more on Programming Utilities 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!