Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. axes(handles.tempplot);
  2. s = daq.createSession('ni') % Create a DAQ Session for the NI DAQ card
  3. s.addAnalogInputChannel('Dev1','ai0','Voltage');
  4. % Add a NI Device (Dev1),
  5. % add an analog input% channel (ai0) and
  6. % specify it as a Voltage
  7. % inputs.Rate = 20;
  8. % Specify the sampling
  9. % rate (20 Hz here)
  10. listboxItems = get(handles.timerange, 'String');
  11. % Get the user selected values from timerange as a string and
  12. % store as array
  13. trange=get(handles.timerange,'Value');
  14. % Get the user selected value by the
  15. % time range box
  16. selectedItem = str2double(listboxItems(trange));
  17. % Obtain string and convert
  18. s.DurationInSeconds = selectedItem;
  19. % Specify the duration in
  20. % seconds based on selected
  21. valuedata = s.startForeground();
  22. % Start data logging.
  23. % Data will be stored in
  24. % the variable "data"
  25. k = s.Rate*s.DurationInSeconds;
  26. % Specify the size of the
  27. % array that stores the
  28. % time stamps
  29. time(1) = 0;
  30. % Initialize the 1st
  31. % element of the time
  32. % stamps as zero
  33. for i=1:k-1
  34. time(i+1) = time(i) + 1/s.Rate;
  35. % Compute the values of
  36. % the time stamps and
  37. % store the values in the
  38. % "time" array
  39. end
  40. scale = [transpose(time), data];
  41. % Store the transpose of
  42. % "time" and "data" in the
  43. % 2-D array "scale"
  44. hold all
  45. plot(time.', data)
  46. % Plot a time plot of the
  47. % load cell data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement