Porblem with ode 45 solver

1 visualización (últimos 30 días)
imran
imran el 30 de Oct. de 2015
Comentada: Torsten el 2 de Nov. de 2015
hi I am trying to solve nonlinear state space int the form
xdot= Ax+R(x,u)
y= S(x,u)
i have written a function given below
function xdot = system(t,x,u)
Tab=sqrt(2/3)*[cos(x(1)) cos(x(1)-2*pi/3) cos(x(1)+2*pi/3)
-sin(x(1)) -sin(x(1)-2*pi/3) -sin(x(1)+2*pi/3)
1/sqrt(2) 1/sqrt(2) 1/sqrt(2)]
wc=2*pi*50;
L=1.35e-3;
R=.056;
C=50e-6;
Rc=.131;
Lc=0.96e-3;
P=10e3;
Q=5e3;
KpllI=5000;
KpPPL=2.1;
Kid2=460;
Kpd2=1;
Kiq2=460;
Kpq2=1;
udq= Tab*u;
A=[0 KpllI 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 -sqrt(2)*wc 0 wc*wc 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 -sqrt(2)*wc 0 wc*wc 0 0 0 0 0 0 0 0 0 0 0
0 0 -1 0 0 0 0 0 1 0 0 0 0 0 -1 0 0
0 0 0 -1 0 0 0 0 0 1 0 0 0 0 0 -1 0
0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 -R/L 0 0 -1/L 0 0 0 0 0
0 0 0 0 0 0 0 0 0 -R/L 0 0 -1/L 0 0 0 0
0 0 0 0 0 0 0 0 0 0 -R/L 0 0 -1/L 0 0 0
0 0 0 0 0 0 0 0 1/C 0 0 0 0 0 -1/C 0 0
0 0 0 0 0 0 0 0 0 1/C 0 0 0 0 0 -1/C 0
0 0 0 0 0 0 0 0 0 0 1/C 0 0 0 0 0 -1/C
0 0 0 0 0 0 0 0 0 0 0 1/Lc 0 0 -Rc/Lc 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1/Lc 0 0 -Rc/Lc 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -Rc/Lc];
w= KpllI*x(2)+KpPPL*udq(2);
vld=Kid2*x(7)+Kpd2*(x(3)-x(9))+udq(1)-w*L*x(10);
vlq=Kiq2*x(8)+Kpq2*(x(4)-x(10))+udq(2)-w*L*x(9);
;
R=[KpPPL*udq(2) % u(2)= voq
udq(2)
0
0
(udq(1)*P-udq(2)*Q)/((udq(2).^2)+(udq(1).^2))
(udq(1)*P+udq(2)*Q)/((udq(2).^2)+(udq(1).^2))
0
0
(vld*1/L)+w*x(10)
(vlq*1/L)-w*x(9)
0
w*x(13)
-w*x(12)
0
(-udq(1)*1/Lc)+w*x(16)
(-udq(2)*1/Lc)+w*x(15)
0];
xdot=A*x+R;
and the main file with
t=0:100e-5:5;
wc=50;
u= [240*sqrt(2)*sin(wc*t+pi/2)
240*sqrt(2)*sin(wc*t-2*pi/3+pi/2)
240*sqrt(2)*sin(wc*t+2*pi/3+pi/2)];
x0=zeros(17,1);
odeOptions = odeset('RelTol',1e-6);
[t,y] = ode45(@system,t,x0,odeOptions,u);
Tab=sqrt(2/3)*[cos(y(:,1)) cos(y(:,1)-2*pi/3) cos(y(:,1)+2*pi/3)
-sin(y(:,1)) -sin(y(:,1)-2*pi/3) -sin(y(:,1)+2*pi/3)
1/sqrt(2) 1/sqrt(2) 1/sqrt(2)];
udq= Tab*u;
The problem i am facing is that multiplication in the last line of code is giving error while in function file it gives no error but do not save the result. Kindly any body suggest me what i am doing wrong. Thanks

Respuesta aceptada

Torsten
Torsten el 30 de Oct. de 2015
y(:,1), y(:,2) and y(:,3) are vectors of length numel(t).
So your matrix Tab is no longer 3x3.
Best wishes
Torsten.
  2 comentarios
imran
imran el 30 de Oct. de 2015
so then what do you suggest i have to use a for loop to compute Tab at each time step using a for loop or is there any other way around this problem?
Torsten
Torsten el 2 de Nov. de 2015
so then what do you suggest i have to use a for loop to compute Tab at each time step using a for loop
That's exactly what I suggest you should do.
Best wishes
Torsten.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by