Switch-Mode Power Converters: Design and Analysis

N1=19;
N2=12;
Lm=1150*N1^2*10^-9;
rw=0.1;
Ron=0.2;
Roff=10^7;
L1=102*10^-6;
rL1=0.005;
Vg=28;
L2=385*10^-6;
rL2=0.077;
RL=5;
fs=125*10^3;
T=1/fs;
C9=100*10^-6;
rc1=0.01;
VD=0.5;
Vref=2.5;
A=10^5;
R35=9.76*10^3;
R70=11.11*10^3;
kf=R35/(R35+R70);
Rp=(rc1*RL)/(rc1+RL);
k=RL/(rc1+RL);
R12=2*10^3;
R45=24.3*10^3;
C37=560*10^-12;
C29=2200*10^-12;
R43=10*10^3;
Vbe=0.7;
R20=5.11*10^3;
R33=2.94*10^3;
hfe=150;
R19=5.11*10^3;
R31=6.65*10^3;
R39=33.2*10^3;
C39=560*10^-12;
C7=60*10^-6;
rc2=2.61;
C8=60*10^-6;
Rx=50*10^6;
Du=0.328;
a11=-(rL1+Rp)/L1-((rw + Ron)*(N2/N1)^2)/L1;
a12=-k/L1;
a18=N2/(L1*N1);
a19=-N2*(rw+Ron)/(L1*N1);
a21=Rp/(rc1*C9);
a22=(k-1)/(rc1*C9);
a31=-(A*kf*Rp)/((1+A)*R12*C37);
a32=-(A*kf*k)/((1+A)*R12*C37);
a33=-A/((1+A)*R45*C37)-1/(R45*C29);
a34=(A/((1+A)*C37))*(1/R12+1/R45+(1+A)/Rx)+1/(R45*C29);
a41=(kf*Rp)/((1+A)*R12*C37);
a42=(kf*k)/((1+A)*R12*C37);
a43=1/((1+A)*R45*C37);
a44=-(1/((1+A)*C37))*(1/R12+1/R45+(1+A)/Rx);
Kb2=(A*R20)/(R20*R43+(1+hfe)*R33*(R20+R43));
a54=((hfe*R31*R19/(R31+R19))/((1+A)*R31*C39))*Kb2;
a55=(R19/((R19+R31)*R31)-1/R31-(1+A)/R39)/(1+A)*C39);
a66=-rL2/L2;
a68=-1/L2;
a77=-1/(rc2*C7);
a78=1/(rc2*C7);
a81=-N2/(N1*C8);
a86=1/C8;
a87=1/(rc2*C8);
a88=-a87;
a89=-a86;
a91=-N2*(rw+Ron)/(N1*Lm);
a98=1/Lm;
a99=-(rw+Ron)/Lm;
A1 = [ a11 a12 0 0 0 0 0 a18 a19; a21 a22 0 0 0 0 0 0 0; a31 a32 a33 a34 0 0 0 0 0;a41 a42 a43 a44 0 0 0 0 0;0 0 0 a54 a55 0 0 0 0;0 0 0 0 0 a66 0 a68 0;0 0 0 0 0 0 a77 a78 0;a81 0 0 0 0 a86 a87 a88 a89;a91 0 0 0 0 0 0 a98 a99];
b1=-VD/L1;
b3=-A^2*Vref/((1+A)*Rx*C37);
b4=A*Vref/((1+A)*Rx*C37);
Kb1=(-R43*(10-VD)+(R20+R43)*(10-Vbe)-A*R20*Vref)/(R20*R43+(1+hfe)*R33*(R20+R43));
b5=((hfe*R31*R19/(R31+R19))/((1+A)*R31*C39))*Kb1+(A*Vref)/((1+A)*R39*C39);
b6=Vg/L2;
B=[b1;0;b3;b4;b5;b6;0;0;0];
d11=-(rL1+Rp)/L1;
d99=-(rw+Roff)/Lm;
A2 = [ d1 1 a12 0 0 0 0 0 0 0; a21 a22 0 0 0 0 0 0 0; a31 a32 a33 a34 0 0 0 0 0;a41 a42 a43 a44 0 0 0 0 0;0 0 0 a54 a55 0 0 0 0;0 0 0 0 0 a66 0 a68 0;0 0 0 0 0 0 a77 a78 0;0 0 0 0 0 a86 a87 a88 a89;0 0 0 0 0 0 0 a98 d99];
A3=A1*Du*T;
A4=A2*(1-Du)*T;
I=eye(9,9);
X1=inv(I-expm(A4)*expm(A3))*(-expm(A4)*inv(A1)*(I-expm(A3))*B-inv(A2)*(I-expm(A4))*B)
X2=expm(A3)*X1-inv(A1)*(I-expm(A3))*B
Y1=[];
for t=0:T/100:Du*T;
Y1=[Y1 expm(A1*t)*X1-inv(A1)*(I-expm(A1*t))*B];
end