|
- %% Plot theory only
- S = asymptote(S_smaller,S_larger,f,Fc);
- P = mod(P,pi);
-
- figure;
- subplot(2,1,1);
- semilogx(f,A,f,S)
- ylabel('Magnitude [dB]','Fontsize',10);
- xlabel('Frequency [Hz]','Fontsize',10);
- legend('Theory','Asymptote');
- grid on
- title('RLC-circuit Bodeplot Theory')
- subplot(2,1,2);
- semilogx(f,P)
- ylabel('Phase [rad]','Fontsize',10);
- xlabel('Frequency [Hz]','Fontsize',10);
- legend('Theory');
- grid on
-
- %% Run the measurements
- if theory_only == false
- data = transferFunction(oscilloscope,functiongenerator,f_start,f_stop,amplitude,n_steps,n_measurements);
- %% Process the data
- A_mean = mean(data.magnitude);
- P_mean = mean(data.phase);
- A_std = std(data.magnitude);
- P_std = std(data.phase);
-
- %% plot average measurement, theory and asymptote.
- figure;
- subplot(2,1,1);
- semilogx(data.frequency,20*log10(A_mean),f,A,f,S)
- ylabel('Magnitude [dB]','Fontsize',10);
- xlabel('Frequency [Hz]','Fontsize',10);
- legend('Average Measurement','Theory','Asymptote');
- grid on
- title('RLC-circuit Bodeplot')
- subplot(2,1,2);
- semilogx(data.frequency,P_mean,f,P)
- ylabel('Phase [rad]','Fontsize',10);
- xlabel('Frequency [Hz]','Fontsize',10);
- legend('Average Measurement','Theory');
- grid on
-
- %% plot avearage measurement with standard deviation and theory.
- figure;
- ax = subplot(2,1,1);
- ax.XScale = 'log';
- errorbar(data.frequency,20*log10(A_mean),20*log10(A_std))
- hold on
- semilogx(f,A)
- hold off
- ylabel('Magnitude [dB]','Fontsize',10);
- xlabel('Frequency [Hz]','Fontsize',10);
- legend('Average Measurement','Theory','Asymptote');
- grid on
- title('RLC-circuit Bodeplot')
- ax = subplot(2,1,2);
- ax.XScale = 'log';
- errorbar(data.frequency,P_mean,P_std);
- hold on
- semilogx(data.frequency,P_mean,f,P)
- hold off
- ylabel('Phase [rad]','Fontsize',10);
- xlabel('Frequency [Hz]','Fontsize',10);
- legend('Average Measurement','Theory');
- grid on
- %% plot avearage measurement with standard deviation.
- figure;
- ax = subplot(2,1,1);
- ax.XScale = 'log';
- errorbar(data.frequency,20*log10(A_mean),20*log10(A_std))
- ylabel('Magnitude [dB]','Fontsize',10);
- xlabel('Frequency [Hz]','Fontsize',10);
- legend('Average Measurement');
- grid on
- title('RLC-circuit Bodeplot')
- ax = subplot(2,1,2);
- ax.XScale = 'log';
- errorbar(data.frequency,P_mean,P_std);
- ylabel('Phase [rad]','Fontsize',10);
- xlabel('Frequency [Hz]','Fontsize',10);
- legend('Average Measurement');
- grid on
- end
|