Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: continuous acquisition
Date: Wed, 5 Dec 2007 12:42:57 +0000 (UTC)
Organization: DW-TV
Lines: 55
Message-ID: <fj66ch$sgs$1@fred.mathworks.com>
References: <fj60m2$p81$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1196858577 29212 172.30.248.35 (5 Dec 2007 12:42:57 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 5 Dec 2007 12:42:57 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1095707
Xref: news.mathworks.com comp.soft-sys.matlab:440934



%% Create TWO *.m-files from this functions

% first *.m-file
function plotaqcuiredata

N = 1024;
SampRate= 44100;

%% Create Plot
figure(1)
hPlot = plot(zeros(1,N));
axis([0 N -2 2]);
grid on;

%% create 'LineIn'
ai      = analoginput('winsound');
chan    = addchannel(ai,1);

handles.N     = N;
handles.ai    = ai;
handles.hPlot = hPlot;

%% config LineIn
set(ai,'SampleRate'             , SampRate);
set(ai,'SamplesPerTrigger'      , inf);
set(ai,'SamplesAcquiredFcnCount', N);
set(ai,'SamplesAcquiredFcn'     , {@update_plot, handles});


start(ai);
pause(5);
stop(ai);




% second *.m-file
function update_plot(dummy1, dummy2, handles)
    
%% get aqcuired data from ai-Object
data = getdata(handles.ai,handles.N);
%% try also 
% data = peekdata(handles.ai,handles.N);

%% plot data
set(handles.hPlot,'YData',data);




%% ---------- End --%

% now call plotaqcuiredata from command window

LARS