Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

25 рядки
1.1KB

  1. function data = transferFunction(oscilloscope,functiongenerator,f_start,f_stop,amplitude,n_steps,n_measurements)
  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_measurements,n_steps);
  10. data = struct('magnitude',emptydata,'phase',emptydata,'frequency',f_array,'measurements',n_measurements,'steps',n_steps);
  11. for j = 1:n_measurements
  12. for i = 1:n_steps
  13. % fprintf('Measurement %i of %i - Frequency: %.2f Hertz\n',i,n_steps,f_array(i));
  14. functiongenerator.frequency = f_array(i);
  15. oscilloscope.run;
  16. oscilloscope.auto;
  17. wavedata = oscilloscope.waveform(1:2,'DEF','SAMP');
  18. [data.phase(j,i),data.magnitude(j,i)] = phamag(wavedata.ch1,wavedata.ch2,wavedata.length,f_array(i),wavedata.sampletime);
  19. end
  20. end
  21. %bodePlot(data.magnitude,data.phase,data.frequency)
  22. end