hemmad

Matlab_Function

May 2nd, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.51 KB | None | 0 0
  1. function [Sopt]   =MC_control(I_ref,Io,Ve,Is,Vs)
  2.  
  3. global Ts R L Aq11 Aq12 Aq21 Aq22 Bq11 Bq12 Bq21 Bq22 S
  4.  
  5.  
  6. Irefalpha = 2*(I_ref(1) - 0.5*I_ref(2) - 0.5*I_ref(3))/3;
  7. Irefbeta = 2*(sqrt(3)*I_ref(2)*0.5 - sqrt(3)*I_ref(3)*0.5)/3;
  8.  
  9. eopt=100;
  10. gopt = 10000000000;
  11.  
  12.  
  13. for k= 1:27;
  14.    
  15.     Ie = S(:,:,k)*Io;
  16.    
  17.     Is_p_3f = Aq21*Ve + Aq22*Is + Bq21*Vs + Bq22*Ie;
  18.    
  19.     Is_p_re = 2*(Is_p_3f(1) - 0.5*Is_p_3f(2)- 0.5*Is_p_3f(3))/3;
  20.    
  21.     Is_p_im = 2*(sqrt(3)*Is_p_3f(2)*0.5- sqrt(3)*Is_p_3f(3)*0.5)/3;
  22.    
  23.     VxN = S(:,:,k)*Ve;
  24.     Vo=[0;0;0];
  25.    
  26.     Vo(1) = VxN(1) -(VxN(1) + VxN(2) + VxN(3))/3;
  27.     Vo(2) = VxN(2) -(VxN(1) + VxN(2) + VxN(3))/3;
  28.     Vo(3) = VxN(3) -(VxN(1) + VxN(2) + VxN(3))/3;
  29.    
  30.     Io_p_3f = (1 - R*Ts/L)*Io + (Ts/L)*Vo;
  31.    
  32.     Io_p_re = 2*(Io_p_3f(1) - 0.5*Io_p_3f(2)- 0.5*Io_p_3f(3))/3;
  33.    
  34.     Io_p_im = 2*(sqrt(3)*Io_p_3f(2)*0.5- sqrt(3)*Io_p_3f(3)*0.5)/3;
  35.    
  36.     Vs_p_3f = Vs;
  37.    
  38.     Vs_p_re = 2*(Vs_p_3f(1) - 0.5*Vs_p_3f(2)- 0.5*Vs_p_3f(3))/3;
  39.    
  40.     Vs_p_im = 2*(sqrt(3)*Vs_p_3f(2)*0.5- sqrt(3)*Vs_p_3f(3)*0.5)/3;
  41.    
  42.     g1 = (abs(Irefalpha - Io_p_re) + abs(Irefbeta-Io_p_im));
  43.     g2 = abs(Vs_p_re*Is_p_im - Vs_p_im*Is_p_re);
  44.     g = g1 + A*g2;
  45.    
  46.     if (g<gopt)
  47.         gopt = g;
  48.         eopt = k;
  49.     end
  50. end
  51.  
  52. SAa = S(1,1,eopt);
  53. SBa = S(1,2,eopt);
  54. SCa = S(1,3,eopt);
  55. SAb = S(2,1,eopt);
  56. SBb = S(2,2,eopt);
  57. SCb = S(2,3,eopt);
  58. SAc = S(3,1,eopt);
  59. SBc = S(3,2,eopt);
  60. SCc = S(3,3,eopt);
  61.  
  62. Sopt = [SAa SBa SCa SAb SBb SCb SAc SBc SCc];
Add Comment
Please, Sign In to add comment