選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

88 行
2.6KB

  1. %% Plot theory only
  2. S = asymptote(S_smaller,S_larger,f,Fc);
  3. P = mod(P,pi);
  4. figure;
  5. ax1 = subplot(2,1,1);
  6. semilogx(f,A,f,S)
  7. ylabel('Magnitude [dB]','Fontsize',10);
  8. xlabel('Frequency [Hz]','Fontsize',10);
  9. xlim([f_start,f_stop]);
  10. legend('Theory','Asymptote');
  11. grid on
  12. title('RC-circuit Bodeplot Theory')
  13. ax2 = subplot(2,1,2);
  14. semilogx(f,P)
  15. ylabel('Phase [rad]','Fontsize',10);
  16. xlabel('Frequency [Hz]','Fontsize',10);
  17. xlim([f_start,f_stop]);
  18. legend('Theory');
  19. grid on
  20. linkaxes([ax1,ax2],'x')
  21. %% Run the measurements
  22. if theory_only == false
  23. data = transferFunction(oscilloscope,functiongenerator,f_start,f_stop,amplitude,n_steps,n_measurements);
  24. %% Process the data
  25. A_mean = mean(data.magnitude);
  26. P_mean = mean(data.phase);
  27. A_std = std(data.magnitude);
  28. P_std = std(data.phase);
  29. %% plot average measurement, theory and asymptote.
  30. figure;
  31. ax1 = subplot(2,1,1);
  32. semilogx(data.frequency,20*log10(A_mean),f,A,f,S)
  33. ylabel('Magnitude [dB]','Fontsize',10);
  34. xlabel('Frequency [Hz]','Fontsize',10);
  35. legend('Average Measurement','Theory','Asymptote');
  36. grid on
  37. title('RC-circuit Bodeplot')
  38. ax2 = subplot(2,1,2);
  39. semilogx(data.frequency,P_mean,f,P)
  40. ylabel('Phase [rad]','Fontsize',10);
  41. xlabel('Frequency [Hz]','Fontsize',10);
  42. legend('Average Measurement','Theory');
  43. grid on
  44. %% plot avearage measurement with standard deviation and theory.
  45. figure;
  46. ax1 = subplot(2,1,1);
  47. ax1.XScale = 'log';
  48. errorbar(data.frequency,20*log10(A_mean),20*log10(A_std))
  49. hold on
  50. semilogx(f,A)
  51. hold off
  52. ylabel('Magnitude [dB]','Fontsize',10);
  53. xlabel('Frequency [Hz]','Fontsize',10);
  54. legend('Average Measurement','Theory','Asymptote');
  55. grid on
  56. title('RC-circuit Bodeplot')
  57. ax2 = subplot(2,1,2);
  58. ax2.XScale = 'log';
  59. errorbar(data.frequency,P_mean,P_std);
  60. hold on
  61. semilogx(data.frequency,P_mean,f,P)
  62. hold off
  63. ylabel('Phase [rad]','Fontsize',10);
  64. xlabel('Frequency [Hz]','Fontsize',10);
  65. legend('Average Measurement','Theory');
  66. grid on
  67. %% plot avearage measurement with standard deviation.
  68. figure;
  69. ax1 = subplot(2,1,1);
  70. ax1.XScale = 'log';
  71. errorbar(data.frequency,20*log10(A_mean),20*log10(A_std))
  72. ylabel('Magnitude [dB]','Fontsize',10);
  73. xlabel('Frequency [Hz]','Fontsize',10);
  74. legend('Average Measurement');
  75. grid on
  76. title('RC-circuit Bodeplot')
  77. ax2 = subplot(2,1,2);
  78. ax2.XScale = 'log';
  79. errorbar(data.frequency,P_mean,P_std);
  80. ylabel('Phase [rad]','Fontsize',10);
  81. xlabel('Frequency [Hz]','Fontsize',10);
  82. legend('Average Measurement');
  83. grid on
  84. end