You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 line
959B

  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 = 10.^linspace(log10(f_start),log10(f_stop),n_steps);
  5. functiongenerator.voltage = amplitude;
  6. functiongenerator.waveform = 'SINUSOID';
  7. oscilloscope.enable_channels;
  8. oscilloscope.trigger.source = 'CH1';
  9. emptydata = zeros(n_steps,1);
  10. data = struct('magnitude',emptydata,'phase',emptydata,'frequency',f_array);
  11. for i = 1:n_steps
  12. fprintf('Measurement %f of %f - Frequency: %.2f Hertz\n',i,n_steps,f_array(i));
  13. functiongenerator.frequency = f_array(i);
  14. oscilloscope.auto;
  15. wavedata = oscilloscope.waveform(1:2);
  16. [data.phase(i),data.magnitude(i)] = phamag(wavedata.ch1,wavedata.ch2,wavedata.length,f_array(i),wavedata.sampletime);
  17. end
  18. %bodePlot(data.magnitude,data.phase,data.frequency)
  19. end