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!