No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

35 líneas
1.5KB

  1. function data = transferFunction(oscilloscope,functiongenerator,f_start,f_stop,amplitude,n_steps,n_measurements,type)
  2. %TRANSFERFUNCTION Summary of this function goes here
  3. % Detailed explanation goes here
  4. if nargin < 8
  5. type = 'HRES';
  6. if nargin < 7
  7. n_measurements = 1;
  8. end
  9. end
  10. f_array = 10.^linspace(log10(f_start),log10(f_stop),n_steps);
  11. functiongenerator.voltage = amplitude;
  12. functiongenerator.waveform = 'SINUSOID';
  13. oscilloscope.enable_channels;
  14. oscilloscope.trigger.source = 'CH1';
  15. oscilloscope.ch1.probe = 1;
  16. oscilloscope.ch2.probe = 1;
  17. emptydata = zeros(n_measurements,n_steps);
  18. data = struct('magnitude',emptydata,'phase',emptydata,'frequency',f_array,'measurements',n_measurements,'steps',n_steps);
  19. for j = 1:n_measurements
  20. for i = 1:n_steps
  21. % fprintf('Measurement %i of %i - Frequency: %.2f Hertz\n',i,n_steps,f_array(i));
  22. functiongenerator.frequency = f_array(i);
  23. oscilloscope.message(['Run: ' num2str(j) '/' num2str(n_measurements) ' - Step: ' num2str(i) '/' num2str(n_steps)])
  24. oscilloscope.run;
  25. oscilloscope.auto;
  26. wavedata = oscilloscope.waveform(1:2,'DEF',type);
  27. [data.phase(j,i),data.magnitude(j,i)] = phamag(wavedata.ch1,wavedata.ch2,wavedata.length,f_array(i),wavedata.sampletime);
  28. end
  29. end
  30. oscilloscope.message('Measurement Finished!');
  31. %bodePlot(data.magnitude,data.phase,data.frequency)
  32. end