Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- axes(handles.tempplot);
- s = daq.createSession('ni') % Create a DAQ Session for the NI DAQ card
- s.addAnalogInputChannel('Dev1','ai0','Voltage');
- % Add a NI Device (Dev1),
- % add an analog input
- % channel (ai0) and
- % specify it as a Voltage
- % input
- s.Rate = 20;
- % Specify the sampling
- % rate (20 Hz here)
- listboxItems = get(handles.timerange, 'String');
- % Get the user selected values from timerange as a string and
- % store as array
- trange=get(handles.timerange,'Value');
- % Get the user selected value by the
- % time range box
- selectedItem = str2double(listboxItems(trange));
- % Obtain string and convert
- s.DurationInSeconds = selectedItem;
- % Specify the duration in
- % seconds based on selected value
- data = s.startForeground();
- % Start data logging.
- % Data will be stored in
- % the variable "data"
- k = s.Rate*s.DurationInSeconds;
- % Specify the size of the
- % array that stores the
- % time stamps
- time(1) = 0;
- % Initialize the 1st
- % element of the time
- % stamps as zero
- for i=1:k-1
- time(i+1) = time(i) + 1/s.Rate;
- % Compute the values of
- % the time stamps and
- % store the values in the
- % "time" array
- end
- scale = [transpose(time), data];
- % Store the transpose of
- % "time" and "data" in the
- % 2-D array "scale"
- hold all
- plot(time.', data)
- % Plot a time plot of the
- % load cell data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement