PDA

View Full Version : matlab question


Johnie
Mar18-04, 06:25 PM
Below shows code that I wrote for a problem that I'm trying to solve,

function der = dqind(t,x);
%ids=x(1);iqs=x(2);idr=x(3);iqr=x(4);x(5)=wm;
poles=6;
w=2*pi*60;
Lm=15/w;
Ls=0.15/w + Lm;
Lr=0.1/w + Lm;
Rs=0.2;Rr=0.1;J=0.5;B=0.1;
dqabcT=[1 -0.5 -0.5;0 sqrt(3)/2 -sqrt(3)/2;1 1 1];
inductor_matrix = [Ls 0 Lm 0;0 Ls 0 Lm;Lm 0 Lr 0;0 Lm 0 Lr];
inverse_of_inductor_matrix=inv(inductor_matrix);
if (t<=10) V=220/sqrt(3);
else V=220;
end;
Vst=[V*sin(w*t);V*sin(w*t-2*pi/3);V*sin(w*t-4*pi/3)];
Vdqs=dqabcT*Vst;
Vvector=[Vdqs(1:2,1);0;0];
wo=x(5,1)*poles/2;
speed_voltage_matrix = [Rs 0 0 0;0 Rs 0 0; 0 wo*Lm Rr wo*Lr;-wo*Lm 0 -wo*Lr Rr];
Torque=(poles/3)*(x(3)*x(2)-x(1)*x(4));
der=inverse_of_inductor_matrix*(Vvector-speed_voltage_matrix*x(1:4,1));
der(5,1)=(Torque - B*x(5,1))/J;

When I run the above code, I get what I expected. I now what to do something a little different which requires me to transform my solutions using a matrix.
So, what I want to do exactly is solve the above diff. equation (ie.
[t,x]=ode23(@dqind,.....);) and tranform every solution that it computes with a matrix (ex. [1 4 5 3; 3 5 2 7; 3 4 5 6; 3 5 4 3])

In order to do this, would I need to include this matrix transform in the M-File that I call to solve the above code ?
Would I write another M-File ?

Thanks