MATLAB Answers

Nichlas
0

Data Aquisition Toolbox, Session-Based Interfaces - Saving processed data during startBackground for later use

Asked by Nichlas
on 14 Dec 2011
Latest activity Commented on by Daniel Nieto on 19 Aug 2014
Hello!
I have been looking around various forums and sites in order to find an answer to this question, but am yet to find anything which helps me with my problem, so hoping someone has some ideas here :)
I am writing an application which retrieves data from an NI USB-6009 device and displays it in a graph, in real-time. This I can achieve easily by creating a listener that plots the data in the specified graph, the problem is to retrieve that data after the aquisition has completed and then perform various tasks on this.
Here is a small part of my code that might explain my situation further;
handles.data = zeros(ai.Channels.Count,ai.NumberOfScans);
lh = ai.addlistener('DataAvailable',@(src,event)plotData(handles,src,event));
ai.startBackground();
Using this setup I call the function plotData and am able to use the handles to find the appropriate graph to plot the data in.
In the function plotData I wish to save the data so that I can somehow use this later, I tried to initialise a handles.data object to save the data in. The problem is that it seems the updating of handles.data in the function is not seen in the main function.
Here is the function plotData:
function plotData(handles,src,event)
data = event.Data;
set(handles.p_t0,'XData',event.TimeStamps);
set(handles.p_t0,'YData',data(:,1));
handles.data(1,(event.TimeStamps*src.Rate)+1) = data(:,1)';
% set(handles.data(1,(event.TimeStamps*src.Rate)+1),data(:,1)')
end
This does not change the value of the handles.data object, have also tried using the set-function without success.
Any ideas on how I am to save this data so that I can access it after the aquisition has been completed?
Cheers! /Nichlas
P.S The indexes on the data object is merely to do with using multiple channels during retrieving... D.S

  2 Comments

Just plugged in a new NI DAQ in 64-bit session mode, and rapidly came to the same point as this poster - works great plotting, but how to retrieve data from startBackground? No answer or comment posted for a long time? Is this possible?

Sign in to comment.

0 Answers