25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

33 satır
1.4KB

  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. emptydata = zeros(n_measurements,n_steps);
  16. data = struct('magnitude',emptydata,'phase',emptydata,'frequency',f_array,'measurements',n_measurements,'steps',n_steps);
  17. for j = 1:n_measurements
  18. for i = 1:n_steps
  19. % fprintf('Measurement %i of %i - Frequency: %.2f Hertz\n',i,n_steps,f_array(i));
  20. functiongenerator.frequency = f_array(i);
  21. oscilloscope.message(['Run: ' num2str(j) '/' num2str(n_measurements) ' - Step: ' num2str(i) '/' num2str(n_steps)])
  22. oscilloscope.run;
  23. oscilloscope.auto;
  24. wavedata = oscilloscope.waveform(1:2,'DEF',type);
  25. [data.phase(j,i),data.magnitude(j,i)] = phamag(wavedata.ch1,wavedata.ch2,wavedata.length,f_array(i),wavedata.sampletime);
  26. end
  27. end
  28. oscilloscope.message('Measurement Finished!');
  29. %bodePlot(data.magnitude,data.phase,data.frequency)
  30. end