Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

25 lines
979B

  1. function data = transferFunction(oscilloscope,functiongenerator,f_start,f_stop,n_steps,amplitude)
  2. %TRANSFERFUNCTION Summary of this function goes here
  3. % Detailed explanation goes here
  4. f_array = linspace(f_start,f_stop,n_steps);
  5. functiongenerator.voltage = amplitude;
  6. functiongenerator.waveform = 'SINUSOID';
  7. oscilloscope.enable_channels;
  8. oscilloscope.trigger.source = 'CH1';
  9. oscilloscope.ch1.type = 'HRES';
  10. oscilloscope.ch2.type = 'HRES';
  11. oscilloscope.setMeasurement(1,'phase');
  12. oscilloscope.setMeasurement(2,'peak');
  13. oscilloscope.setMeasurement(3,'peak','ch2');
  14. emptydata = zeros(n_steps,1);
  15. data = struct('magnitude',emptydata,'phase',emptydata,'frequency',f_array);
  16. for i = 1:n_steps
  17. functiongenerator.frequency = f_array(i);
  18. oscilloscope.auto;
  19. data.phase(i) = oscilloscope.getMeasurement(1);
  20. data.magnitude(i) = oscilloscope.getMeasurement(2)/oscilloscope.getMeasurement(3);
  21. end
  22. end