[matlab] codes-c-systems

Viewer

copydownloadembedprintName: codes-c-systems
  1. %time vs voltage subplot for sin and cos wave subplot and exp cos wave
  2. clc
  3. clear all
  4. f=50;
  5. tp=1/f;
  6. fs=1000;
  7. ts=1/fs;
  8. t=0:ts:3*tp;
  9. x=cos(2*pi*f*t);
  10. subplot(3,1,1);
  11. plot(t,x);
  12. grid on
  13. title('cos wave');
  14. xlabel('time(s)');
  15. ylabel('voltage(v)');
  16. x2=sin(2*pi*f*t);
  17. subplot(3,1,2)
  18. plot(t,x2);
  19. grid on
  20. title('sin wave');
  21. xlabel('time(s)');
  22. ylabel('voltage(v)');
  23.  
  24. %exponential plot for at
  25. clc 
  26. clear all
  27. a=10;
  28. f=50;
  29. tp=1/f;
  30. fs=1000;
  31. ts=1/fs;
  32. t=0:ts:3*tp;
  33. x=exp(a*t).*cos(2*pi*f*t);
  34. subplot(3,1,3);
  35. plot(t,x);
  36. title('exponential cos wave')
  37. xlabel('time(s)')
  38. ylabel('voltage(v)')
  39.  
  40.  
  41. %impulse and step response while keeping tf=25/s^2+5s+25 
  42. sys=tf([0 0 25],[1 5 25]);
  43. subplot(2,1,1)
  44. impulse(sys);
  45. subplot(2,1,2);
  46. step(sys);
  47.  
  48.  
  49. %exp 3
  50. clc
  51. clear all
  52. sys=tf([0 0 25],[1 5 25]);
  53. stepinfo(sys)
  54. ltiview(sys)
  55.  
  56.  
  57. %exp 4
  58. clc
  59. clear all
  60. g1=tf([0 0 1],[1 25 1]);
  61. h=tf([0 1 2],[0 0 1]);
  62. g2=tf([0 1 1],[0 0 2]);
  63. f=feedback(g1,h,-1);
  64. ltiview(f);
  65.  
  66.  
  67.  
  68. %exp 5
  69. %to design a feedback controller for a open loop system given by
  70. %g(s)=s+7/s(s-5)(s+15)(s+20) such that the overshoot is 5% and risetime is
  71. %1 sec and unity feedback
  72.  
  73. clc
  74. clear all
  75. z=-7;
  76. p=[0;5;-15;-20];
  77. k=1;
  78. g=zpk(z,p,k);
  79. g
  80. rlocus(g)
  81. zeta=0.7;
  82. w=1.8;
  83. sgrid(zeta,w);
  84. [k,poles]=rlocfind(g);
  85. h=feedback(g*k,1,-1);
  86. stepinfo(h);
  87. ltiview(h);
  88.  
  89.  
  90. %exp 6
  91. %to design a feedback controller for a open loop system given by
  92. %g(s)=s+7/s(s-5)(s+15)(s+20) such that the overshoot is 5% and risetime is
  93. %1 sec and unity feedback
  94.  
  95. clc
  96. clear all
  97. z=-7;
  98. p=[0;5;-15;-20];
  99. k=1;
  100. g=zpk(z,p,k);
  101. g
  102. rlocus(g)
  103. zeta=0.7;
  104. w=1.8;
  105. sgrid(zeta,w);
  106. [k,poles]=rlocfind(g);
  107. h=feedback(g*k,1,-1);
  108. stepinfo(h);
  109. ltiview(h);

Editor

You can edit this paste and save as new:


File Description
  • codes-c-systems
  • Paste Code
  • 28 Apr-2024
  • 1.68 Kb
You can Share it: