How do I specify which channel I want to use to output data in the Data Acquisition Toolbox?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I want to output two different data sets at different times from my computer's sound card. I know how to add two channels to my output, but when I'm sending the data, how do I specify to Matlab which channel I want to use? I want to get data from y1 to go through ch1 and data from y2 to go through ch2.
My current code:
ao=analogoutput('winsound');
addchannel(ao,1);
addchannel(ao,2);
zero=zeros(15001,1);
Fs=8000;
t=0:1/Fs:.25;
y1=sin(2*pi*440*t)';
y2=sin(2*pi*600*t)';
putdata(ao,[y1 zero])
start(ao)
wait(ao,3)
stop(ao)
putdata(ao, [zero y2])
start(ao)
wait(ao,3)
stop(ao)
delete(ao)
clear ao
Thanks!
0 Kommentare
Antworten (1)
Sean de Wolski
am 1 Aug. 2012
It's been awhile size I've done this but doesn't each column of the data go to the respective channel as it was created. Consider the doc putdata example with a few small modifications:
ao = analogoutput('nidaq','Dev1');
ch = addchannel(ao,0:1);
set(ao,'SampleRate',1000)
data1 = linspace(0,1,10000)';
data2 = rand(size(data1));
putdata(ao,[data1 data2])
start(ao)
Here data2 will go to the second channel (1) and data 1 will go the first (0) from when these were added with addchannel. Swapping the inputs would reverse this.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Data Acquisition Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!