Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Timer object to rquest data from txt file

2 visualizzazioni (ultimi 30 giorni)
Camilo
Camilo il 22 Feb 2016
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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 Commento
jgg
jgg il 22 Feb 2016
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

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by