Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

116 wiersze
2.9KB

  1. classdef Channel
  2. %CHANNEL Summary of this class goes here
  3. % Detailed explanation goes here
  4. properties
  5. scope
  6. channelnumber
  7. end
  8. properties (Dependent)
  9. state
  10. coupling
  11. bandwidth
  12. scale
  13. offset
  14. probe
  15. label
  16. end
  17. methods
  18. function ch = Channel(scope,channelnumber)
  19. ch.channelnumber = channelnumber;
  20. ch.scope = scope;
  21. end
  22. function s = get.state(ch)
  23. s = ch.scope.query(ch.CHAN('state?'));
  24. end
  25. function out = get.coupling(ch)
  26. out = ch.scope.query(ch.CHAN('coup?'));
  27. end
  28. function out = get.bandwidth(ch)
  29. out = ch.scope.query(ch.CHAN('band?'));
  30. end
  31. function out = get.offset(ch)
  32. out = ch.scope.query(ch.CHAN('offs?'));
  33. end
  34. function out = get.scale(ch)
  35. out = ch.scope.query(ch.CHAN('scal?'));
  36. end
  37. function out = get.label(ch)
  38. out = ch.scope.query(ch.CHAN('lab?'));
  39. end
  40. function ch = set.state(ch,in)
  41. ch.scope.write(ch.CHANsend('state',in));
  42. end
  43. function ch = set.coupling(ch,in)
  44. ch.scope.write(ch.CHANsend('coup',in));
  45. end
  46. function ch = set.bandwidth(ch,in)
  47. ch.scope.write(ch.CHANsend('band',in));
  48. end
  49. function ch = set.offset(ch,in)
  50. ch.scope.write(ch.CHANsend('offs',in));
  51. end
  52. function ch = set.scale(ch,in)
  53. ch.scope.write(ch.CHANsend('scal',in));
  54. end
  55. function ch = set.label(ch,in)
  56. ch.scope.write(ch.CHANsend('lab',in));
  57. end
  58. function out = frequency(ch)
  59. out = str2double(ch.MEAS('freq'));
  60. end
  61. function out = peak2peak(ch)
  62. out = str2double(ch.MEAS('peak'));
  63. end
  64. function out = period(ch)
  65. out = str2double(ch.MEAS('per'));
  66. end
  67. function out = amplitude(ch)
  68. out = str2double(ch.MEAS('ampl'));
  69. end
  70. function out = mean(ch)
  71. out = str2double(ch.MEAS('mean'));
  72. end
  73. function out = rms(ch)
  74. out = str2double(ch.MEAS('rms'));
  75. end
  76. function out = phase(ch)
  77. out = str2double(ch.MEAS('phas'));
  78. end
  79. end
  80. methods (Hidden, Access = private)
  81. function c = CHAN(ch,string)
  82. c = ['CHAN',num2str(ch.channelnumber),':',string];
  83. end
  84. function c = MEAS(ch,string)
  85. c = ch.scope.query(['MEAS',num2str(ch.channelnumber),':RES:ACT?',string]);
  86. end
  87. function c = CHANsend(ch,string,in)
  88. c = ['CHAN',num2str(ch.channelnumber),':',string,' ',in];
  89. end
  90. end
  91. end