Advertisement
Guest User

New one

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