Advertisement
lucontre

%%euler circuito RLC con EDO segundo grado easy mode

Sep 4th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.83 KB | None | 0 0
  1. %%euler circuito RLC con EDO segundo grado
  2. clear all
  3. clc
  4.  
  5. %constantes
  6.  
  7. h=0.0001; %sampleo, delta t, tiempo de musetreo , tamaΓ±o de paso ,.. etc
  8. L=440e-3 ;   %inductancia
  9. C=47e-6  ;  %capacitancia
  10. R=100   ;  %resistencia
  11. %conste de simulacion
  12. tFin=2      %[segundos]
  13. kFin=(tFin/h)+1  
  14. orden =1      
  15.  
  16. %valores iniciales
  17. x1(1)=0;
  18. x2(1)=0;
  19.  
  20. for k=1:kFin
  21.     %vector tiempo
  22.     t(k)=(k-1)*h;
  23.     %vector volteje entrada
  24.     if t(k)>1
  25.         V(k)=50*sin(2*pi*1000*t(k));
  26.     else
  27.         V(k)=0;
  28.     end
  29.    
  30.     if k <(kFin-orden+1)
  31.        % Vc(k+2)=(h^2/(L*C))*V(k) + (2-R*h/L)*Vc(k+1)+(-1-(h^2/(L*C))+(R/L)*h)*Vc(k);
  32.         x1(k+1)= x1(k) + x2(k)*h;
  33.          x2(k+1)= (h/(L*C))*V(k) - (h/(L*C))*x1(k) + (1-(R*h/L))*x2(k);
  34.     end
  35.    
  36. end
  37.  Vc=x1;
  38.  figure(2)
  39.  
  40.  plot(t,V), hold on
  41.  plot(t,Vc,'m'), hold off
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement