Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Timer object to rquest data from txt file
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello everyone
I want to fix my problem. I am trying to request data from a txt file generated every 1 minute with new data. The code I am using is:
% Matlab code
function time_object
%Creating timer object
t = timer('TimerFcn',@request_data,'ExecutionMode','fixedRate','Period',1,'TasksToExecute',Inf);
start(t);
function request_data
path = 'C:\Users\fullfilename.txt';
data = dlmread(path, ';', 2, 2);
value = data(:,3);
fprintg('Data: %f\n',value)
end
% End of my code
I'd like to print new data every minute when my txt file is generated but nothing happens at the moment. Someone knows how is the correct wat to define a timer object? ... if it is possible I'd like to run time at specific time as well.
I've seen some examples using datenow to upload time but I do not how to do it.
Thanks for your support. Camilo
댓글 수: 1
jgg
2016년 2월 22일
I'm unclear what the issue is? This seems to work well for me:
t = timer('BusyMode','drop','ExecutionMode','fixedRate', 'Period', 10,'StartFcn',@(varargin)(tic),'TimerFcn',@(varargin)(toc))
You'd want your period to be 60. I also see this would handle your starting time problem: http://www.mathworks.com/help/matlab/ref/timer.startat.html
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!