Error on queueOutputData(): The data argument must contain one column for each output channel in the session. Taking Transpose of dataOut gives same error.
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Trevor Voss
am 27 Apr. 2018
Kommentiert: Trevor Voss
am 30 Apr. 2018
Hello all,
I have been working for some time now to understand and fix an error I keep getting in MatLab. I keep getting the error mentioned in the title. I will paste my code below... Basically I have an output (controls a flashing LED) which is split with a BNC T splitter into an Input on a different DAQ. All I want to do is be able to output two graphs that are exactly the same... one from the output, and one from the input.
Through my searching online I found the solution of simply taking the transpose of dataOut (or AnalogOut1 in my case), and this did not work. To try and understand the issue more, I made some simplified dummy code that has a separate input and output. I was able to get to the same error, and in this case taking the transpose of dataOut worked perfectly. However this does not work within the code I need to get working (below).
I am thinking it may have to do with DataVec, however I am relatively new at MatLab, so troubleshooting this myself is proving quite difficult. (I'm using the NI PCI-6733, and NI PCIe-6323).
Thanks for any help....
_____________________________________________________________________________________________________________
function AnalogInputTest(ST)
% ROIs should be
%%Scanning Variables
numLED=1; % number of channels (LED num + opto laser)
TExp=0.0085; % use to set frame rate, affects period of trigger pulse
FR=round(1/TExp); % frame rate
NumFrame=round(FR*ST); % calculated total number of frames
%%AO control
outV=5; % output trigger height (volts)
Sr=10000; % sampling rate
s=daq.createSession('ni');
s.Rate = Sr;
Ar = s.Rate;
addAnalogOutputChannel(s, 'Dev1', 'ao1', 'Voltage'); % Blue LED (TL 470)
ch2=addAnalogInputChannel(s,'Dev2','ai0','Voltage');
s
%%Adaptive Control MatrixG
LEDtime=round([25]); %Blue, Yellow Orange, Red
SpF=floor(Ar/FR); %samples per Frame (or per LED)
clear DataVec
DataVec=zeros(numLED*SpF,size(s.Channels,2));
for n=0:numLED-1
DataVec((1+n*SpF+round(SpF./2-LEDtime(n+1)./2)):(1+n*SpF+round(SpF./2+LEDtime(n+1)./2)),n+2)=1;
end
%%Concatenate Everything Together
DataVec=outV*DataVec;
DataVecOff=DataVec;
AnalogOut1=repmat(DataVecOff,round(ST*Sr/(numLED*SpF)),1);
[time] = size(AnalogOut1,1);
%%to TTL Voltage
numtrig=size(find(AnalogOut1(:,1)>4.5),1);
numtrig=numtrig/LEDtime;
%%Begin Scanning
disp('Press ENTER when ready to start flashing sequence.')
pause
disp('Playing encoding sequence.')
queueOutputData(s,AnalogOut1');
data=startForeground(s);
[ch2,time] = s.startForeground();
plot(ch2);
plot(data);
release(s);
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 27 Apr. 2018
You have one input channel and one output channel, so
DataVec=zeros(numLED*SpF,size(s.Channels,2));
will be something-by-2.
You have
numLED=1; % number of channels (LED num + opto laser)
for n=0:numLED-1
DataVec((1+n*SpF+round(SpF./2-LEDtime(n+1)./2)):(1+n*SpF+round(SpF./2+LEDtime(n+1)./2)),n+2)=1;
end
With numLED being 1, then that is n=0:0, and the n+2 takes that to offset 2, so you are writing into DataVec(:,2), so DataVec will certainly have (at least) 2 channels.
Your
AnalogOut1=repmat(DataVecOff,round(ST*Sr/(numLED*SpF)),1);
is not going to change the number of output columns, so AnalogOut1 is going to have two output channels.
You
queueOutputData(s,AnalogOut1');
which would be queuing 2 x something. Without the ' (which appears to be an attempt to get the code to work) that would be something x 2.
However: you need to queue with one column for each output channel, not with one column for each channel including input channels.
queueOutputData(s, AnalogOut1(:,2:2+numLED-1))
9 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!