I have a question that I dont know how to figure it out. I am plotting my real time data obtained from temperature sensors in MATLAB. The sensor software generates the text file for each sensor and updates it after every minute. What do I have to do if I want the plot to be updated after certain period of time; let's say after 10 or 20 values or after every 5 mins.
Asked
Active
Viewed 2,847 times
1
-
related question: [Using MATLAB to process files in real-time after every instance a file is created by a separate program](http://stackoverflow.com/questions/7532825/using-matlab-to-process-files-in-real-time-after-every-instance-a-file-is-created) – Amro Oct 06 '11 at 03:22
2 Answers
2
You could use a timer.
Reusing the code of Nzbuu, it would be something like the following
function ReadAndUpdate
[X,Y] = readFile(); % Read file
set(h, 'XData', X, 'YData', Y) % Update line data
end
t = timer('TimerFcn',@ReadAndUpdate, 'Period', 5*60, ...
'ExecutionMode', 'fixedDelay')
start(t)
Here the function is trigged infinitely but you can stop
it or set a condition.

Clement J.
- 3,012
- 26
- 29
-
Thanks..it worked very fine One more questión that I have plotted some 16 plots using subplot but the graph seems qauite small, so i wana add scroll bar..any ideas how to accomplish this scroll bar thing with some function – mirage Sep 28 '11 at 14:37
-
1It's probably possible by putting your subplots in an uipanel (and the uipanel in a figure). Edit : Have a look at http://www.mathworks.com/matlabcentral/fileexchange/24265-scrollbar-gui-example/content/GUIexample.m. – Clement J. Sep 30 '11 at 06:38
0
Assuming you have a function readFile
that reads the data from the file. You can do the following for something quick and dirty.
h = plot(NaN, NaN);
while true
[X,Y] = readFile(); % Read file
set(h, 'XData', X, 'YData', Y) % Update line data
pause(5*60) % Wait 5 minutes
end

Nzbuu
- 5,241
- 1
- 29
- 51