|
- function data = transferFunction(oscilloscope,functiongenerator,f_start,f_stop,amplitude,n_steps,n_measurements,type)
- %TRANSFERFUNCTION Summary of this function goes here
- % Detailed explanation goes here
- if nargin < 8
- type = 'HRES';
- if nargin < 7
- n_measurements = 1;
- end
- end
-
- f_array = 10.^linspace(log10(f_start),log10(f_stop),n_steps);
- functiongenerator.voltage = amplitude;
- functiongenerator.waveform = 'SINUSOID';
- oscilloscope.enable_channels;
- oscilloscope.trigger.source = 'CH1';
- oscilloscope.ch1.probe = 1;
- oscilloscope.ch2.probe = 1;
- emptydata = zeros(n_measurements,n_steps);
- data = struct('magnitude',emptydata,'phase',emptydata,'frequency',f_array,'measurements',n_measurements,'steps',n_steps);
- for j = 1:n_measurements
- for i = 1:n_steps
- % fprintf('Measurement %i of %i - Frequency: %.2f Hertz\n',i,n_steps,f_array(i));
- functiongenerator.frequency = f_array(i);
- oscilloscope.message(['Run: ' num2str(j) '/' num2str(n_measurements) ' - Step: ' num2str(i) '/' num2str(n_steps)])
- oscilloscope.run;
- oscilloscope.auto;
- wavedata = oscilloscope.waveform(1:2,'DEF',type);
- [data.phase(j,i),data.magnitude(j,i)] = phamag(wavedata.ch1,wavedata.ch2,wavedata.length,f_array(i),wavedata.sampletime);
- end
- end
- oscilloscope.message('Measurement Finished!');
- %bodePlot(data.magnitude,data.phase,data.frequency)
- end
|