Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: continuous acquisition
Date: Wed, 12 Dec 2007 20:04:39 +0000 (UTC)
Organization: DW-TV
Lines: 83
Message-ID: <fjpesn$p3d$1@fred.mathworks.com>
References: <fj60m2$p81$1@fred.mathworks.com> <fj66ch$sgs$1@fred.mathworks.com> <fj6cug$2vu$1@fred.mathworks.com> <fj9d6l$97$1@fred.mathworks.com> <fjb0ua$cfc$1@fred.mathworks.com> <fjbaqs$mu0$1@fred.mathworks.com> <fjbgs7$ggp$1@fred.mathworks.com> <fjbr8b$qi7$1@fred.mathworks.com> <fjma9f$8d4$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1197489879 25709 172.30.248.37 (12 Dec 2007 20:04:39 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 12 Dec 2007 20:04:39 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1095707
Xref: news.mathworks.com comp.soft-sys.matlab:442217



say your data is

>> data = [1 2 3 4 5];

then 

>> mean(a) = 3 (!!!)

now lets say

>> a = [1 2 3 4 5; 6 7 8 9 10]

then 

>> mean(a) = 3.5 4.5 5.5 6.5 7.5

You need more than one set of samples.
Create an array lets say handles.myarray = zeros(10,
length_N) and a counter (say handles.counter=1) in the
openingFcn.

now you can compute insight the update_plot - routine
(It works like a register...) the following:

% write fresh data in selected row of myarray
handles.myarray(handles.counter, :)=getdata(handles.ai);
% compute mean of myarray
toPlot = mean(handles.myarray) 
% increment lineselection
handles.counter = handles.counter+1;

% register full, overwrite from first row
if handles.counter==10
   handles.counter = 1;
end


note that you must insert 

>> handles = guidata(handles.figure1);

at the beginning of update_plot and

>> guidata(handles.figure1, handles);  

at the end of update_plot since handles are sent to
update_plot only at initiation of function as
SamplesAcquiredFcn which you did in openingFcn.





An example of mine looks loke this (slightly shortened):


function update_plot(hObject, eventdata, handles)

handles = guidata(handles.figure1);       
     
inpt = getdata(handles.ai,handles.N_in);
  
handles.AvgMat(handles.AvgCount,:) = inpt';             
inpt = mean(handles.AvgMatRotate);

if handles.AvgNumCount == handles.rotations
   handles.AvgNumCount = 1;
end

handles.AvgCount = handles.AvgCount + 1;   


set(handles.hPlotSpec,'YData', inpt);  
       
guidata(handles.figure1, handles);            

     
    
  
Hope it helps!
LARS