problem with 'PLOT' while plotting data acquired from NI DAQ Board

I am trying to acquire data (Square wave with certain amplitude) from an amplifier unit using NI DAQ Board and trying to plot(amplitude v/s time) the same. I dont have a hardware trigger for this circuitry. When i execute the program i am getting an error msg.
'Undefined function 'Plot' for input arguments of type 'double'.
Error in dataread (line 36)
Plot (time, data);
below is my code. can you please help me on how to over come this error.
i
p.TriggerTimeout = 2; %If there is no trigger signal after 2 seconds time out
p.no_of_measurements = 50;
p.SampleRate = 2000000; %Maximum samplerate for NI USB-6361
p.InputRange = [-2 2]; %Amplifier output DAQ AI options [-10 10], [-5 5], [-2 2],[-1 1],[-500 500], [-200 200], [-100 100]
p.AInputChannel = 0;
p.Frequency = 5; %in kHz
p.noise = 0.065;
p.no_of_measurementRuns = 6;
ai = analoginput ('nidaq','Dev1');
ch = addchannel(ai,p.AInputChannel,{'PD'}); %Connect the amplifier output to AI0(+) and AI0(-) NRSE
ch.InputRange = p.InputRange;
ai.SampleRate = p.SampleRate; %samples per second
%set(ai, 'TriggerType','Software');
%set(ai, 'HwDigitalTriggerSource', 'PFI0');
%set(ai, 'TriggerCondition','PositiveEdge');
%set(ai,'LogFileName','file01.daq')
%set(ai,'LoggingMode','Disk&Memory')
duration = 10;
disp('press a key to acquired data')
w = waitforbuttonpress;
if w == 0
disp('Button clicked')
else
disp('Key pressed')
end
start (ai);
wait (ai, duration+1);
[data, time] = getdata (ai);
Plot (time, data);
%[data, time] = daqread ('file01.daq');

回答 (1 件)

Mischa Kim
Mischa Kim 2014 年 2 月 12 日
編集済み: Mischa Kim 2014 年 2 月 12 日

0 投票

Shailendra, plot needs to be spelled lower-case:
plot(time, data)

4 件のコメント

Shailendra
Shailendra 2014 年 2 月 12 日
Mischa, thank for the quick reply. now its working. :)
I have another question. I expected that the plot would come for recording of 10 seconds as the code included (duration = 10;) and also ('wait (ai, duration+1); )
But now i can see the plot only for 0.5 milli Second only. I tried changing the duration values, still i can see only 0.5 milli second recordings. What could be the reason?
Mischa Kim
Mischa Kim 2014 年 2 月 13 日
Hard to say. Without having worked with this particular H/W and just looking at your code I would guess that the answer lies in the parameters: number of measurements, sampling frequency, etc., would result in a data acquisition time period that would be in the 0.5 ms range. But that's really just a guess.
Shailendra
Shailendra 2014 年 2 月 13 日
no prob, i could solved the issue, i got some reference and i could acquire the data. Thanks a lot for your help. :D
i
p.TriggerTimeout = 2; %If there is no trigger signal after 2 seconds time out
p.no_of_measurements = 50;
p.InputRange = [-2 2]; %Amplifier output DAQ AI options [-10 10], [-5 5], [-2 2],[-1 1],[-500 500], [-200 200], [-100 100]
p.AInputChannel = 0;
p.Frequency = 5; %in kHz
p.noise = 0.065;
p.no_of_measurementRuns = 6;
ai = analoginput ('nidaq','Dev1');
ch = addchannel(ai,p.AInputChannel,{'PD'}); %Connect the amplifier output to AI0(+) and AI0(-) NRSE
duration = 10;
set(ai,'SampleRate',20000)
ActualRate = get(ai,'SampleRate');
set(ai,'SamplesPerTrigger',duration*ActualRate)
set(ai,'TriggerType','Manual')
blocksize = get(ai,'SamplesPerTrigger');
Fs = ActualRate;
ch.InputRange = p.InputRange;
start (ai);
trigger(ai)
wait(ai,duration + 1)
[data, time] = getdata (ai);
plot (time, y);
Mischa Kim
Mischa Kim 2014 年 2 月 13 日
Excellent. Would you mind formally accepting the answer, sort of as "problem solved"?

サインインしてコメントする。

カテゴリ

質問済み:

2014 年 2 月 12 日

コメント済み:

2014 年 2 月 13 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by