Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. close all
  2. clear all
  3. %frequency range
  4. f=[0.1:0.2:10000];
  5. %Circuit elements values
  6. Res=1e3;
  7. cap=1e-6;
  8. % Capacitor's impedance
  9. i=sqrt(-1);
  10. ZCap=1./(i*2*pi*f*cap);
  11.  
  12. % Transfer function (TF)
  13. H=ZCap./(Res+ZCap);
  14. Phase=angle(H);
  15. Amp=abs(H);
  16.  
  17. % Semi log plot of Amplitude of TF
  18. figure(1)
  19. hold on;
  20. subplot(2,1,1)
  21. semilogx(f,20*log10(Amp),'b');
  22. grid on
  23. title('Log magnitude of TF')
  24. xlabel('Frequency [Hz]')
  25. ylabel('dB Magnitude [dB]')
  26.  
  27. % Semi log plot of Amplitude of TF (manual)
  28. figure(2)
  29. hold on;
  30. subplot(2,1,1)
  31. plot(log10(f),20*log10(Amp),'b');
  32. xticks(log10([[0.1:0.1:1] [2:1:10] [20:10:100] [200:100:1000] [2000:1000:10000]]));
  33. X_Label=[{'0.1'} repmat({''},1,8) {'1'} repmat({''},1,8) {'10'} repmat({''},1,8) {'100'} ...
  34. repmat({''},1,8) {'1000'} repmat({''},1,8) {'10000'}];
  35. xticklabels(X_Label)
  36. grid on
  37. title('Log magnitude of TF')
  38. xlabel('Frequency [Hz]')
  39. ylabel('dB Magnitude [dB]')
  40.  
  41. % Semi log plot of Phase of TF
  42. figure(1)
  43. subplot(2,1,2)
  44. semilogx(f,Phase.*180/pi,'r')
  45. grid on
  46. title('Phase of TF')
  47. xlabel('Frequency [Hz]')
  48. ylabel('Phase [Degrees]')
  49.  
  50. % Semi log plot of Phase of TF (manual)
  51. figure(2)
  52. subplot(2,1,2)
  53. plot(log10(f),Phase.*180/pi,'r')
  54. xticks(log10([[0.1:0.1:1] [2:1:10] [20:10:100] [200:100:1000] [2000:1000:10000]]));
  55. xticklabels(X_Label)
  56. grid on
  57. title('Phase of TF')
  58. xlabel('Frequency [Hz]')
  59. ylabel('Phase [Degrees]')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement