How do I specify which channel I want to use to output data in the Data Acquisition Toolbox?
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Sean de Wolski
2012-8-1
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Acquisition Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!