I would like to use the read option of TasksExecuted
in a timer callback function. How could I proceed? Here is my program draft:
period=5
a = timer('ExecutionMode','fixedRate','Period',period,'TimerFcn',{@time_append,period,TasksExecuted, HR, fictiveFolderName},'TasksToExecute',3 );
start(a);
function time_append(obj,event,period,TasksExecuted, HR, fictiveFolderName)
HR_freq=1;
print(TasksExecuted);
i_init=TasksExecuted*period*HR_freq 1
i_end=(TasksExecuted 1)*period*HR_freq
writematrix(HR(i_init:i_end),strcat(fictiveFolderName,'\HR.csv'),'WriteMode','append');
end
where HR
is a 100x1 doubles matrix and fictiveFolderName
an existing folder containing a csv file called HR. I get the error Unrecognized function or variable 'TasksExecuted'
. There is only little information about read-only properties of callback functions available in the documentation.
How can I use the read property of TasksExecuted
?
CodePudding user response:
The property you are after is a property of the timer object. Within your callback function you would have access to it as obj.TasksExecuted
.
You won’t have access to it when creating the timer object (the line a=timer…
where you get an error), because then the timer object doesn’t exist yet.