MATLAB: Plotting real time data in matlab with Ni-daq, but view the entire graph as it is plotting

continuous acquisitionreal time data plot

Hi 🙂
I have some problems with some matlab code.
I want to make the code in matlab which can display a live plot of the data that I collect with a measuring instrument from national instruments (Ni-daq 6009), the signal I need to collect an EMG signal, which then represented as a real-time plot matlab.
So far I have made the following code from examples from mathworks http://se.mathworks.com/help/daq/examples/acquire-continuous-and-background-data-using-ni-devices.html, but it is constantly updating the axes so that the plot does not appear in just one plot with fixed x and y axes, but constantly updating, so i can only view one second at a time . But I want to show the graph in a plot which has a fixed x and y axis (eg. X, 0500, y, -500,500) and from there the signal is displayed as a running line in the same plot.
The code I have so far:
s = daq.createSession('ni');
addAnalogInputChannel(s,'Dev2', 0, 'Voltage');
s.Rate = 5000;
s.DurationInSeconds = 10;
s.NotifyWhenDataAvailableExceeds = 1000;
s
lh = addlistener(s,'DataAvailable', @(src,event) plot(event.TimeStamps,
event.Data));
s.startBackground();
Hope someone can help, i would be very thankfull 🙂

Best Answer

This page and this page in the doc are pretty good introductions to some of the techniques you need here. Basically what you're missing is a call to drawnow that tells MATLAB that you want to update the figure.
Related Question