How do I specify which channel I want to use to output data in the Data Acquisition Toolbox?
6 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Sean de Wolski
on 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 Comments
See Also
Categories
Find more on Data Acquisition Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!